[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/dbal/src/drivers/mysql/ -> lmbMysqlDbInfo.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  lmb_require('limb/dbal/src/drivers/lmbDbInfo.class.php');
  10  lmb_require('limb/dbal/src/drivers/mysql/lmbMysqlTableInfo.class.php');
  11  
  12  /**

  13   * class lmbMysqlDbInfo.

  14   *

  15   * @package dbal

  16   * @version $Id: lmbMysqlDbInfo.class.php 5945 2007-06-06 08:31:43Z pachanga $

  17   */
  18  class lmbMysqlDbInfo extends lmbDbInfo
  19  {
  20    protected $connection;
  21    protected $isExisting = false;
  22    protected $isTablesLoaded = false;
  23  
  24    function __construct($connection, $name, $isExisting = false)
  25    {
  26      $this->connection = $connection;
  27      $this->isExisting = $isExisting;
  28      parent::__construct($name);
  29    }
  30  
  31    function getConnection()
  32    {
  33      return $this->connection;
  34    }
  35  
  36    function loadTables()
  37    {
  38      if($this->isExisting && !$this->isTablesLoaded)
  39      {
  40        $queryId = $this->connection->execute("SHOW TABLES FROM `" . $this->name . "`");
  41        while(is_array($row = mysql_fetch_row($queryId)))
  42        {
  43          $this->tables[$row[0]] = null;
  44        }
  45        mysql_free_result($queryId);
  46        $this->isTablesLoaded = true;
  47      }
  48    }
  49  
  50    function getTable($name)
  51    {
  52      if(!$this->hasTable($name))
  53      {
  54        throw new lmbDbException("Table does not exist '$name'");
  55      }
  56      if(is_null($this->tables[$name]))
  57      {
  58        $this->tables[$name] = new lmbMysqlTableInfo($this, $name, true);
  59      }
  60      return $this->tables[$name];
  61    }
  62  }
  63  
  64  ?>


Generated: Mon Sep 8 04:35:41 2008 Cross-referenced by PHPXref 0.7