[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/dbal/src/drivers/pgsql/ -> lmbPgsqlDbInfo.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/pgsql/lmbPgsqlTableInfo.class.php');
  11  
  12  /**

  13   * class lmbPgsqlDbInfo.

  14   *

  15   * @package dbal

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

  17   */
  18  class lmbPgsqlDbInfo 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  
  41        $result = $this->connection->execute("SELECT oid, relname FROM pg_class
  42                                                  WHERE relkind = 'r' AND relnamespace = (SELECT oid
  43                                                    FROM pg_namespace
  44                                                    WHERE
  45                                                         nspname NOT IN ('information_schema','pg_catalog')
  46                                                         AND nspname NOT LIKE 'pg_temp%'
  47                                                         AND nspname NOT LIKE 'pg_toast%'
  48                                                    LIMIT 1)
  49                                                  ORDER BY relname");
  50  
  51        while($row = pg_fetch_assoc($result))
  52        {
  53          $this->tables[$row['relname']] = $row['oid'];
  54        }
  55  
  56        pg_free_result($result);
  57        $this->isTablesLoaded = true;
  58      }
  59    }
  60  
  61    function getTable($name)
  62    {
  63      if(!$this->hasTable($name))
  64      {
  65        throw new lmbDbException('Table does not exist ' . $name);
  66      }
  67      if(!is_object($this->tables[$name]))
  68      {
  69        $this->tables[$name] = new lmbPgsqlTableInfo($this, $name, true, $this->tables[$name]);
  70      }
  71      return $this->tables[$name];
  72    }
  73  }
  74  
  75  ?>


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