[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

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

  13   * class lmbOciTableInfo.

  14   *

  15   * @package dbal

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

  17   */
  18  class lmbOciTableInfo extends lmbDbTableInfo
  19  {
  20    protected $database;
  21  
  22    protected $isExisting = false;
  23    protected $isColumnsLoaded = false;
  24  
  25    protected $schema;
  26  
  27    function __construct($database, $name, $schema, $isExisting = false)
  28    {
  29      parent::__construct($name);
  30      $this->schema = $schema;
  31      $this->database = $database;
  32      $this->isExisting = $isExisting;
  33    }
  34  
  35    //Based on code from Creole
  36    function loadColumns()
  37    {
  38      if($this->isExisting && !$this->isColumnsLoaded)
  39      {
  40        $sql = "SELECT COLUMN_NAME, DATA_TYPE, DATA_PRECISION, DATA_LENGTH, DATA_DEFAULT, NULLABLE, DATA_SCALE
  41                FROM ALL_TAB_COLUMNS
  42                WHERE TABLE_NAME = '" . strtoupper($this->name) . "' AND OWNER = '" . strtoupper($this->schema) . "'";
  43  
  44        $connection = $this->database->getConnection();
  45        $result = $connection->execute($sql);
  46  
  47        while($row = oci_fetch_array($result, OCI_ASSOC + OCI_RETURN_NULLS))
  48        {
  49          $this->columns[strtolower($row['COLUMN_NAME'])] =
  50            new lmbOciColumnInfo($this,
  51               strtolower($row['COLUMN_NAME']),
  52               strtolower($row['DATA_TYPE']),
  53               $row['DATA_LENGTH'],
  54               $row['DATA_SCALE'] ,
  55               $row['NULLABLE'] ,
  56               $row['DATA_DEFAULT']);
  57        }
  58        $this->isColumnsLoaded = true;
  59      }
  60    }
  61  
  62    function getDatabase()
  63    {
  64      return $this->database;
  65    }
  66  }
  67  
  68  ?>


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