PageRenderTime 27ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/include/adodb/drivers/adodb-odbc_oracle.inc.php

https://github.com/radicaldesigns/amp
PHP | 115 lines | 80 code | 18 blank | 17 comment | 11 complexity | c6a22f74f1b14ae163d358b0a77196d9 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, BSD-3-Clause, LGPL-2.0, CC-BY-SA-3.0, AGPL-1.0
  1. <?php
  2. /*
  3. V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
  4. Released under both BSD license and Lesser GPL library license.
  5. Whenever there is any discrepancy between the two licenses,
  6. the BSD license will take precedence.
  7. Set tabs to 4 for best viewing.
  8. Latest version is available at http://adodb.sourceforge.net
  9. Oracle support via ODBC. Requires ODBC. Works on Windows.
  10. */
  11. // security - hide paths
  12. if (!defined('ADODB_DIR')) die();
  13. if (!defined('_ADODB_ODBC_LAYER')) {
  14. include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
  15. }
  16. class ADODB_odbc_oracle extends ADODB_odbc {
  17. var $databaseType = 'odbc_oracle';
  18. var $replaceQuote = "''"; // string to use to replace quotes
  19. var $concat_operator='||';
  20. var $fmtDate = "'Y-m-d 00:00:00'";
  21. var $fmtTimeStamp = "'Y-m-d h:i:sA'";
  22. var $metaTablesSQL = 'select table_name from cat';
  23. var $metaColumnsSQL = "select cname,coltype,width from col where tname='%s' order by colno";
  24. var $sysDate = "TRUNC(SYSDATE)";
  25. var $sysTimeStamp = 'SYSDATE';
  26. //var $_bindInputArray = false;
  27. function ADODB_odbc_oracle()
  28. {
  29. $this->ADODB_odbc();
  30. }
  31. function &MetaTables()
  32. {
  33. $false = false;
  34. $rs = $this->Execute($this->metaTablesSQL);
  35. if ($rs === false) return $false;
  36. $arr = $rs->GetArray();
  37. $arr2 = array();
  38. for ($i=0; $i < sizeof($arr); $i++) {
  39. $arr2[] = $arr[$i][0];
  40. }
  41. $rs->Close();
  42. return $arr2;
  43. }
  44. function &MetaColumns($table)
  45. {
  46. global $ADODB_FETCH_MODE;
  47. $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table)));
  48. if ($rs === false) {
  49. $false = false;
  50. return $false;
  51. }
  52. $retarr = array();
  53. while (!$rs->EOF) { //print_r($rs->fields);
  54. $fld = new ADOFieldObject();
  55. $fld->name = $rs->fields[0];
  56. $fld->type = $rs->fields[1];
  57. $fld->max_length = $rs->fields[2];
  58. if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
  59. else $retarr[strtoupper($fld->name)] = $fld;
  60. $rs->MoveNext();
  61. }
  62. $rs->Close();
  63. return $retarr;
  64. }
  65. // returns true or false
  66. function _connect($argDSN, $argUsername, $argPassword, $argDatabasename)
  67. {
  68. global $php_errormsg;
  69. $php_errormsg = '';
  70. $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,SQL_CUR_USE_ODBC );
  71. $this->_errorMsg = $php_errormsg;
  72. $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'");
  73. //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
  74. return $this->_connectionID != false;
  75. }
  76. // returns true or false
  77. function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
  78. {
  79. global $php_errormsg;
  80. $php_errormsg = '';
  81. $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,SQL_CUR_USE_ODBC );
  82. $this->_errorMsg = $php_errormsg;
  83. $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'");
  84. //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
  85. return $this->_connectionID != false;
  86. }
  87. }
  88. class ADORecordSet_odbc_oracle extends ADORecordSet_odbc {
  89. var $databaseType = 'odbc_oracle';
  90. function ADORecordSet_odbc_oracle($id,$mode=false)
  91. {
  92. return $this->ADORecordSet_odbc($id,$mode);
  93. }
  94. }
  95. ?>