[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/dbal/src/drivers/sqlite/ -> lmbSqliteDbInfo.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/sqlite/lmbSqliteTableInfo.class.php');
  11  
  12  /**
  13   * class lmbSqliteDbInfo.
  14   *
  15   * @package dbal
  16   * @version $Id$
  17   */
  18  class lmbSqliteDbInfo 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        $sql = "SELECT name FROM sqlite_master WHERE type='table' UNION ALL " .
  41               "SELECT name FROM sqlite_temp_master WHERE type='table' ORDER BY name;";
  42  
  43        $queryId = $this->connection->execute($sql);
  44        while(sqlite_has_more($queryId))
  45          $this->tables[sqlite_fetch_single($queryId)] = null;
  46  
  47        $this->isTablesLoaded = true;
  48      }
  49    }
  50  
  51    function getTable($name)
  52    {
  53      if(!$this->hasTable($name))
  54        throw new lmbDbException("Table does not exist '$name'");
  55  
  56      if(is_null($this->tables[$name]))
  57        $this->tables[$name] = new lmbSqliteTableInfo($this, $name, true);
  58  
  59      return $this->tables[$name];
  60    }
  61  }
  62  
  63  ?>


Generated: Sat Nov 22 03:48:54 2008 Cross-referenced by PHPXref 0.7