[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/dbal/src/drivers/oci/ -> lmbOciDbInfo.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(dirname(__FILE__) . '/lmbOciTableInfo.class.php');
  11  
  12  /**

  13   * class lmbOciDbInfo.

  14   *

  15   * @package dbal

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

  17   */
  18  class lmbOciDbInfo 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        $config = $this->connection->getConfig();
  41        $schema = strtoupper($config['user']);
  42        $result = $this->connection->execute("SELECT TABLE_NAME FROM ALL_TABLES WHERE OWNER = '$schema'");
  43  
  44        while($row = oci_fetch_assoc($result))
  45        {
  46          $this->tables[strtolower($row['TABLE_NAME'])] = 1;
  47        }
  48  
  49        oci_free_statement($result);
  50        $this->isTablesLoaded = true;
  51      }
  52    }
  53  
  54    function getTable($name)
  55    {
  56      if(!$this->hasTable($name))
  57      {
  58        throw new lmbDbException('Table does not exist ' . $name);
  59      }
  60      if(!is_object($this->tables[$name]))
  61      {
  62        $config = $this->connection->getConfig();
  63        $this->tables[$name] = new lmbOciTableInfo($this, $name, $config['user'], true);
  64      }
  65      return $this->tables[$name];
  66    }
  67  }
  68  
  69  ?>


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