PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/dbal/src/drivers/oci/lmbOciTableInfo.class.php

http://github.com/limb-php-framework/limb
PHP | 74 lines | 49 code | 11 blank | 14 comment | 2 complexity | e0770acefe3cce258dc898fbbd103125 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-3.0, MPL-2.0-no-copyleft-exception, GPL-2.0
  1. <?php
  2. /*
  3. * Limb PHP Framework
  4. *
  5. * @link http://limb-project.com
  6. * @copyright Copyright &copy; 2004-2009 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. * class lmbOciTableInfo.
  13. *
  14. * @package dbal
  15. * @version $Id: lmbOciTableInfo.class.php 7486 2009-01-26 19:13:20Z pachanga $
  16. */
  17. class lmbOciTableInfo extends lmbDbTableInfo
  18. {
  19. protected $database;
  20. protected $isExisting = false;
  21. protected $isColumnsLoaded = false;
  22. protected $schema;
  23. function __construct($database, $name, $schema, $isExisting = false)
  24. {
  25. parent::__construct($name);
  26. $this->schema = $schema;
  27. $this->database = $database;
  28. $this->isExisting = $isExisting;
  29. }
  30. //Based on code from Creole
  31. function loadColumns()
  32. {
  33. if($this->isExisting && !$this->isColumnsLoaded)
  34. {
  35. $sql = "SELECT COLUMN_NAME, DATA_TYPE, DATA_PRECISION, DATA_LENGTH, DATA_DEFAULT, NULLABLE, DATA_SCALE
  36. FROM ALL_TAB_COLUMNS
  37. WHERE TABLE_NAME = '" . strtoupper($this->name) . "' AND OWNER = '" . strtoupper($this->schema) . "'";
  38. $connection = $this->database->getConnection();
  39. $result = $connection->execute($sql);
  40. while($row = oci_fetch_array($result, OCI_ASSOC + OCI_RETURN_NULLS))
  41. {
  42. $this->columns[strtolower($row['COLUMN_NAME'])] =
  43. new lmbOciColumnInfo($this,
  44. strtolower($row['COLUMN_NAME']),
  45. strtolower($row['DATA_TYPE']),
  46. $row['DATA_LENGTH'],
  47. $row['DATA_SCALE'] ,
  48. $row['NULLABLE'] ,
  49. $row['DATA_DEFAULT']);
  50. }
  51. $this->isColumnsLoaded = true;
  52. }
  53. }
  54. function getDatabase()
  55. {
  56. return $this->database;
  57. }
  58. function loadIndexes()
  59. {
  60. lmb_require('limb/core/src/exception/lmbNotYetImplementedException.class.php');
  61. throw new lmbNotYetImplementedException();
  62. }
  63. }