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