16 if (!defined(
'ADODB_DIR')) die();
25 var
$metaColumnsSQL =
"select cname,coltype,width from col where tname='%s' order by colno";
26 var
$sysDate =
"TO_DATE(TO_CHAR(SYSDATE,'YYYY-MM-DD'),'YYYY-MM-DD')";
37 if (is_string($d)) $d = ADORecordSet::UnixDate($d);
38 if (is_object($d)) $ds = $d->format($this->fmtDate);
40 return 'TO_DATE('.$ds.
",'YYYY-MM-DD')";
47 if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts);
48 if (is_object($ts)) $ds = $ts->format($this->fmtDate);
49 else $ds =
adodb_date($this->fmtTimeStamp,$ts);
50 return 'TO_DATE('.$ds.
",'RRRR-MM-DD, HH:MI:SS AM')";
56 $d = ADOConnection::DBDate($d);
57 if (strncmp($d,
"'",1))
return $d;
59 return substr($d,1,strlen($d)-2);
64 $d = ADOConnection::DBTimeStamp($d);
65 if (strncmp($d,
"'",1))
return $d;
67 return substr($d,1,strlen($d)-2);
74 $this->autoCommit =
false;
75 ora_commitoff($this->_connectionID);
83 $ret = ora_commit($this->_connectionID);
84 ora_commiton($this->_connectionID);
91 $ret = ora_rollback($this->_connectionID);
92 ora_commiton($this->_connectionID);
100 if ($this->_errorMsg !==
false)
return $this->_errorMsg;
102 if (is_resource($this->_curs)) $this->_errorMsg = @ora_error($this->_curs);
103 if (empty($this->_errorMsg)) $this->_errorMsg = @ora_error($this->_connectionID);
104 return $this->_errorMsg;
110 if ($this->_errorCode !==
false)
return $this->_errorCode;
112 if (is_resource($this->_curs)) $this->_errorCode = @ora_errorcode($this->_curs);
113 if (empty($this->_errorCode)) $this->_errorCode = @ora_errorcode($this->_connectionID);
114 return $this->_errorCode;
120 function _connect($argHostname, $argUsername, $argPassword, $argDatabasename, $mode=0)
122 if (!function_exists(
'ora_plogon'))
return null;
125 $this->_errorMsg =
false;
126 $this->_errorCode =
false;
133 if (empty($argDatabasename)) $argDatabasename = $argHostname;
135 if(strpos($argHostname,
":")) {
136 $argHostinfo=explode(
":",$argHostname);
137 $argHostname=$argHostinfo[0];
138 $argHostport=$argHostinfo[1];
144 if ($this->connectSID) {
145 $argDatabasename=
"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname
146 .
")(PORT=$argHostport))(CONNECT_DATA=(SID=$argDatabasename)))";
148 $argDatabasename=
"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname
149 .
")(PORT=$argHostport))(CONNECT_DATA=(SERVICE_NAME=$argDatabasename)))";
154 if ($argDatabasename) $argUsername .=
"@$argDatabasename";
158 $this->_connectionID = ora_plogon($argUsername,$argPassword);
160 $this->_connectionID = ora_logon($argUsername,$argPassword);
161 if ($this->_connectionID ===
false)
return false;
162 if ($this->autoCommit) ora_commiton($this->_connectionID);
163 if ($this->_initdate) {
164 $rs = $this->
_query(
"ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'");
165 if ($rs) ora_close($rs);
173 function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
175 return $this->
_connect($argHostname, $argUsername, $argPassword, $argDatabasename, 1);
183 $this->_errorMsg =
false;
184 $this->_errorCode =
false;
186 $curs = ora_open($this->_connectionID);
188 if ($curs ===
false)
return false;
189 $this->_curs = $curs;
190 if (!ora_parse($curs,$sql))
return false;
191 if (ora_exec($curs))
return $curs;
194 $this->_errorCode = @ora_errorcode($curs);
195 $this->_errorMsg = @ora_error($curs);
205 return @ora_logoff($this->_connectionID);
225 if ($mode ===
false) {
226 global $ADODB_FETCH_MODE;
227 $mode = $ADODB_FETCH_MODE;
229 $this->fetchMode = $mode;
231 $this->_queryID = $queryID;
233 $this->_inited =
true;
234 $this->fields = array();
236 $this->_currentRow = 0;
237 $this->EOF = !$this->
_fetch();
240 $this->_numOfRows = 0;
241 $this->_numOfFields = 0;
245 return $this->_queryID;
257 $fld =
new ADOFieldObject;
258 $fld->name = ora_columnname($this->_queryID, $fieldOffset);
259 $fld->type = ora_columntype($this->_queryID, $fieldOffset);
260 $fld->max_length = ora_columnsize($this->_queryID, $fieldOffset);
268 $this->bind = array();
269 for ($i=0; $i < $this->_numOfFields; $i++) {
271 $this->bind[strtoupper($o->name)] = $i;
275 return $this->fields[$this->bind[strtoupper($colname)]];
280 $this->_numOfRows = -1;
281 $this->_numOfFields = @ora_numcols($this->_queryID);
292 if ($this->fetchMode & ADODB_FETCH_ASSOC)
293 return @ora_fetch_into($this->_queryID,$this->fields,ORA_FETCHINTO_NULLS|ORA_FETCHINTO_ASSOC);
295 return @ora_fetch_into($this->_queryID,$this->fields,ORA_FETCHINTO_NULLS);
303 return @ora_close($this->_queryID);
310 $t = $fieldobj->type;
311 $len = $fieldobj->max_length;
314 switch (strtoupper($t)) {
320 if ($len <= $this->blobSize)
return 'C';
326 case 'LONG VARBINARY':
330 case 'DATE':
return 'D';
334 case 'BIT':
return 'L';
337 case 'INTEGER':
return 'I';