Source for file adodb-oracle.inc.php
Documentation is available at adodb-oracle.inc.php
V4.97 22 Jan 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Latest version is available at http://adodb.sourceforge.net
Oracle data driver. Requires Oracle client. Works on Windows and Unix and Oracle 7.
If you are using Oracle 8 or later, use the oci8 driver which is much better and more reliable.
var $metaColumnsSQL = "select cname,coltype,width from col where tname='%s' order by colno";
var $sysDate = "TO_DATE(TO_CHAR(SYSDATE,'YYYY-MM-DD'),'YYYY-MM-DD')";
// format and return date string in database date format
// format and return date string in database timestamp format
/* there seems to be a bug in the oracle extension -- always returns ORA-00000 - no error */
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename, $mode= 0)
// <G. Giunta 2003/03/03/> Reset error messages before connecting
// G. Giunta 2003/08/13 - This looks danegrously suspicious: why should we want to set
// the oracle home to the host name of remote DB?
// if ($argHostname) putenv("ORACLE_HOME=$argHostname");
if($argHostname) { // code copied from version submitted for oci8 by Jorma Tuomainen <jorma.tuomainen@ppoy.fi>
if (empty($argDatabasename)) $argDatabasename = $argHostname;
if(strpos($argHostname,":")) {
$argHostinfo= explode(":",$argHostname);
$argHostname= $argHostinfo[0];
$argHostport= $argHostinfo[1];
$argDatabasename= "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=". $argHostname
. ")(PORT=$argHostport))(CONNECT_DATA=(SID=$argDatabasename)))";
$argDatabasename= "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=". $argHostname
. ")(PORT=$argHostport))(CONNECT_DATA=(SERVICE_NAME=$argDatabasename)))";
if ($argDatabasename) $argUsername .= "@$argDatabasename";
//if ($argHostname) print "<p>Connect: 1st argument should be left blank for $this->databaseType</p>";
$rs = $this->_query("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'");
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename, 1);
// returns query ID if successful, otherwise false
function _query($sql,$inputarr= false)
// <G. Giunta 2003/03/03/> Reset error messages before executing
if (!ora_parse($curs,$sql)) return false;
if (ora_exec($curs)) return $curs;
// <G. Giunta 2004/03/03> before we close the cursor, we have to store the error message
// that we can obtain ONLY from the cursor (and not from the connection)
// </G. Giunta 2004/03/03>
/*--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------*/
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
/* Returns: an object containing field information.
Get column information in the Recordset object. fetchField() can be used in order to obtain information about
fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by
fetchField() is retrieved. */
$fld->name = ora_columnname($this->_queryID, $fieldOffset);
$fld->type = ora_columntype($this->_queryID, $fieldOffset);
$fld->max_length = ora_columnsize($this->_queryID, $fieldOffset);
/* Use associative array to get fields array */
function _fetch($ignore_fields= false) {
// should remove call by reference, but ora_fetch_into requires it in 4.0.3pl1
return @ora_fetch_into($this->_queryID,&$this->fields,ORA_FETCHINTO_NULLS| ORA_FETCHINTO_ASSOC);
return @ora_fetch_into($this->_queryID,&$this->fields,ORA_FETCHINTO_NULLS);
/* close() only needs to be called if you are worried about using too much memory while your script
is running. All associated result memory for the specified result identifier will automatically be freed. */
$len = $fieldobj->max_length;
if ($len <= $this->blobSize) return 'C';
case 'INTEGER': return 'I';
|