]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiDB/adodb/drivers/adodb-odbc_oracle.inc.php
locking table specific for better databases
[SourceForge/phpwiki.git] / lib / WikiDB / adodb / drivers / adodb-odbc_oracle.inc.php
1 <?php
2 /* 
3 V4.22 15 Apr 2004  (c) 2000-2004 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   
9   Latest version is available at http://php.weblogs.com/
10   
11   Oracle support via ODBC. Requires ODBC. Works on Windows. 
12 */
13
14 if (!defined('_ADODB_ODBC_LAYER')) {
15         include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
16 }
17
18  
19 class  ADODB_odbc_oracle extends ADODB_odbc {   
20         var $databaseType = 'odbc_oracle';
21         var $replaceQuote = "''"; // string to use to replace quotes
22         var $concat_operator='||';
23         var $fmtDate = "'Y-m-d 00:00:00'"; 
24         var $fmtTimeStamp = "'Y-m-d h:i:sA'";
25         var $metaTablesSQL = 'select table_name from cat';
26         var $metaColumnsSQL = "select cname,coltype,width from col where tname='%s' order by colno";
27         var $sysDate = "TRUNC(SYSDATE)";
28         var $sysTimeStamp = 'SYSDATE';
29         
30         //var $_bindInputArray = false;
31         
32         function ADODB_odbc_oracle()
33         {
34                 $this->ADODB_odbc();
35         }
36                 
37         function &MetaTables() 
38         {
39                 if ($this->metaTablesSQL) {
40                         $rs = $this->Execute($this->metaTablesSQL);
41                         if ($rs === false) return false;
42                         $arr = $rs->GetArray();
43                         $arr2 = array();
44                         for ($i=0; $i < sizeof($arr); $i++) {
45                                 $arr2[] = $arr[$i][0];
46                         }
47                         $rs->Close();
48                         return $arr2;
49                 }
50                 return false;
51         }
52         
53         function &MetaColumns($table) 
54         {
55                 if (!empty($this->metaColumnsSQL)) {
56                 
57                         $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table)));
58                         if ($rs === false) return false;
59
60                         $retarr = array();
61                         while (!$rs->EOF) { //print_r($rs->fields);
62                                 $fld = new ADOFieldObject();
63                                 $fld->name = $rs->fields[0];
64                                 $fld->type = $rs->fields[1];
65                                 $fld->max_length = $rs->fields[2];
66                                 
67                                 
68                                 if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;     
69                                 else $retarr[strtoupper($fld->name)] = $fld;
70                                 
71                                 $rs->MoveNext();
72                         }
73                         $rs->Close();
74                         return $retarr; 
75                 }
76                 return false;
77         }
78
79         // returns true or false
80         function _connect($argDSN, $argUsername, $argPassword, $argDatabasename)
81         {
82         global $php_errormsg;
83         
84                 $php_errormsg = '';
85                 $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,SQL_CUR_USE_ODBC );
86                 $this->_errorMsg = $php_errormsg;
87                 
88                 $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'");
89                 //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
90                 return $this->_connectionID != false;
91         }
92         // returns true or false
93         function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
94         {
95         global $php_errormsg;
96                 $php_errormsg = '';
97                 $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,SQL_CUR_USE_ODBC );
98                 $this->_errorMsg = $php_errormsg;
99                 
100                 $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'");
101                 //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
102                 return $this->_connectionID != false;
103         }
104
105  
106 class  ADORecordSet_odbc_oracle extends ADORecordSet_odbc {     
107         
108         var $databaseType = 'odbc_oracle';
109         
110         function ADORecordSet_odbc_oracle($id,$mode=false)
111         {
112                 return $this->ADORecordSet_odbc($id,$mode);
113         }
114 }
115 ?>