File: D:/HostingSpaces/MDalebout3/prdct.nl/wwwroot/timesheet/includes/adodb5/drivers/adodb-oracle.inc.php
<?php
/*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). 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.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB_oracle extends ADOConnection {
var $databaseType = "oracle";
var $replaceQuote = "''"; // string to use to replace quotes
var $concat_operator='||';
var $_curs;
var $_initdate = true; // init date to YYYY-MM-DD
var $metaTablesSQL = 'select table_name from cat';
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')";
var $sysTimeStamp = 'SYSDATE';
var $connectSID = true;
function ADODB_oracle()
{
}
// format and return date string in database date format
function DBDate($d)
{
if (is_string($d)) $d = ADORecordSet::UnixDate($d);
if (is_object($d)) $ds = $d->format($this->fmtDate);
else $ds = adodb_date($this->fmtDate,$d);
return 'TO_DATE('.$ds.",'YYYY-MM-DD')";
}
// format and return date string in database timestamp format
function DBTimeStamp($ts)
{
if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts);
if (is_object($ts)) $ds = $ts->format($this->fmtDate);
else $ds = adodb_date($this->fmtTimeStamp,$ts);
return 'TO_DATE('.$ds.",'RRRR-MM-DD, HH:MI:SS AM')";
}
function BindDate($d)
{
$d = ADOConnection::DBDate($d);
if (strncmp($d,"'",1)) return $d;
return substr($d,1,strlen($d)-2);
}
function BindTimeStamp($d)
{
$d = ADOConnection::DBTimeStamp($d);
if (strncmp($d,"'",1)) return $d;
return substr($d,1,strlen($d)-2);
}
function BeginTrans()
{
$this->autoCommit = false;
ora_commitoff($this->_connectionID);
return true;
}
function CommitTrans($ok=true)
{
if (!$ok) return $this->RollbackTrans();
$ret = ora_commit($this->_connectionID);
ora_commiton($this->_connectionID);
return $ret;
}
function RollbackTrans()
{
$ret = ora_rollback($this->_connectionID);
ora_commiton($this->_connectionID);
return $ret;
}
/* there seems to be a bug in the oracle extension -- always returns ORA-00000 - no error */
function ErrorMsg()
{
if ($this->_errorMsg !== false) return $this->_errorMsg;
if (is_resource($this->_curs)) $this->_errorMsg = @ora_error($this->_curs);
if (empty($this->_errorMsg)) $this->_errorMsg = @ora_error($this->_connectionID);
return $this->_errorMsg;
}
function ErrorNo()
{
if ($this->_errorCode !== false) return $this->_errorCode;
if (is_resource($this->_curs)) $this->_errorCode = @ora_errorcode($this->_curs);
if (empty($this->_errorCode)) $this->_errorCode = @ora_errorcode($this->_connectionID);
return $this->_errorCode;
}
// returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename, $mode=0)
{
if (!function_exists('ora_plogon')) return null;
// <G. Giunta 2003/03/03/> Reset error messages before connecting
$this->_errorMsg = false;
$this->_errorCode = false;
// 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;
else {
if(strpos($argHostname,":")) {
$argHostinfo=explode(":",$argHostname);
$argHostname=$argHostinfo[0];
$argHostport=$argHostinfo[1];
} else {
$argHostport="1521";
}
if ($this->connectSID) {
$argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HO