2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Merged from McMasterReports branch

This commit is contained in:
azammitdcarf
2010-01-14 07:45:37 +00:00
parent 18dbb16138
commit d1b139d315
1884 changed files with 555891 additions and 364768 deletions

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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. See License.txt.
@@ -49,7 +49,7 @@ class ADODB_access extends ADODB_odbc {
return " IIF(IsNull($field), $ifNull, $field) "; // if Access
}
/*
function &MetaTables()
function MetaTables()
{
global $ADODB_FETCH_MODE;
@@ -62,7 +62,7 @@ class ADODB_access extends ADODB_odbc {
$rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
$arr = &$rs->GetArray();
$arr = $rs->GetArray();
//print_pre($arr);
$arr2 = array();
for ($i=0; $i < sizeof($arr); $i++) {

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -147,7 +147,7 @@ class ADODB_ado extends ADOConnection {
*/
function &MetaTables()
function MetaTables()
{
$arr= array();
$dbc = $this->_connectionID;
@@ -169,7 +169,7 @@ class ADODB_ado extends ADOConnection {
return $arr;
}
function &MetaColumns($table)
function MetaColumns($table)
{
$table = strtoupper($table);
$arr = array();
@@ -204,7 +204,7 @@ class ADODB_ado extends ADOConnection {
/* returns queryID or false */
function &_query($sql,$inputarr=false)
function _query($sql,$inputarr=false)
{
$dbc = $this->_connectionID;
@@ -221,11 +221,27 @@ class ADODB_ado extends ADOConnection {
$oCmd->CommandText = $sql;
$oCmd->CommandType = 1;
foreach($inputarr as $val) {
// Map by http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmthcreateparam.asp
// Check issue http://bugs.php.net/bug.php?id=40664 !!!
while(list(, $val) = each($inputarr)) {
$type = gettype($val);
$len=strlen($val);
if ($type == 'boolean')
$this->adoParameterType = 11;
else if ($type == 'integer')
$this->adoParameterType = 3;
else if ($type == 'double')
$this->adoParameterType = 5;
elseif ($type == 'string')
$this->adoParameterType = 202;
else if (($val === null) || (!defined($val)))
$len=1;
else
$this->adoParameterType = 130;
// name, type, direction 1 = input, len,
$this->adoParameterType = 130;
$p = $oCmd->CreateParameter('name',$this->adoParameterType,1,strlen($val),$val);
//print $p->Type.' '.$p->value;
$p = $oCmd->CreateParameter('name',$this->adoParameterType,1,$len,$val);
$oCmd->Parameters->Append($p);
}
$p = false;
@@ -337,7 +353,7 @@ class ADORecordSet_ado extends ADORecordSet {
// returns the field object
function &FetchField($fieldOffset = -1) {
function FetchField($fieldOffset = -1) {
$off=$fieldOffset+1; // offsets begin at 1
$o= new ADOFieldObject();
@@ -587,6 +603,16 @@ class ADORecordSet_ado extends ADORecordSet {
ADOConnection::outp( '<b>'.$f->Name.': currency type not supported by PHP</b>');
$this->fields[] = (float) $f->value;
break;
case 11: //BIT;
$val = "";
if(is_bool($f->value)) {
if($f->value==true) $val = 1;
else $val = 0;
}
if(is_null($f->value)) $val = null;
$this->fields[] = $val;
break;
default:
$this->fields[] = $f->value;
break;
@@ -599,7 +625,7 @@ class ADORecordSet_ado extends ADORecordSet {
@$rs->MoveNext(); // @ needed for some versions of PHP!
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields = &$this->GetRowAssoc(ADODB_ASSOC_CASE);
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
}
return true;
}

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -70,7 +70,8 @@ class ADODB_ado extends ADOConnection {
} else {
$argDatabasename = '';
if ($argDBorProvider) $argProvider = $argDBorProvider;
else $argProvider = 'MSDASQL';
else if (stripos($argHostname,'PROVIDER') === false) /* full conn string is not in $argHostname */
$argProvider = 'MSDASQL';
}
@@ -101,6 +102,9 @@ class ADODB_ado extends ADOConnection {
if ($argProvider) $dbc->Provider = $argProvider;
if ($argProvider) $argHostname = "PROVIDER=$argProvider;DRIVER={SQL Server};SERVER=$argHostname";
if ($argDatabasename) $argHostname .= ";DATABASE=$argDatabasename";
if ($argUsername) $argHostname .= ";$u=$argUsername";
if ($argPassword)$argHostname .= ";$p=$argPassword";
@@ -114,6 +118,7 @@ class ADODB_ado extends ADOConnection {
$dbc->CursorLocation = $this->_cursor_location;
return $dbc->State > 0;
} catch (exception $e) {
if ($this->debug);echo "<pre>",$argHostname,"\n",$e,"</pre>\n";
}
return false;
@@ -167,7 +172,7 @@ class ADODB_ado extends ADOConnection {
*/
function &MetaTables()
function MetaTables()
{
$arr= array();
$dbc = $this->_connectionID;
@@ -189,7 +194,7 @@ class ADODB_ado extends ADOConnection {
return $arr;
}
function &MetaColumns($table)
function MetaColumns($table)
{
$table = strtoupper($table);
$arr= array();
@@ -221,7 +226,7 @@ class ADODB_ado extends ADOConnection {
}
/* returns queryID or false */
function &_query($sql,$inputarr=false)
function _query($sql,$inputarr=false)
{
try { // In PHP5, all COM errors are exceptions, so to maintain old behaviour...
@@ -241,13 +246,28 @@ class ADODB_ado extends ADOConnection {
$oCmd->CommandText = $sql;
$oCmd->CommandType = 1;
foreach($inputarr as $val) {
while(list(, $val) = each($inputarr)) {
$type = gettype($val);
$len=strlen($val);
if ($type == 'boolean')
$this->adoParameterType = 11;
else if ($type == 'integer')
$this->adoParameterType = 3;
else if ($type == 'double')
$this->adoParameterType = 5;
elseif ($type == 'string')
$this->adoParameterType = 202;
else if (($val === null) || (!defined($val)))
$len=1;
else
$this->adoParameterType = 130;
// name, type, direction 1 = input, len,
$this->adoParameterType = 130;
$p = $oCmd->CreateParameter('name',$this->adoParameterType,1,strlen($val),$val);
//print $p->Type.' '.$p->value;
$p = $oCmd->CreateParameter('name',$this->adoParameterType,1,$len,$val);
$oCmd->Parameters->Append($p);
}
$p = false;
$rs = $oCmd->Execute();
$e = $dbc->Errors;
@@ -367,11 +387,13 @@ class ADORecordSet_ado extends ADORecordSet {
// returns the field object
function &FetchField($fieldOffset = -1) {
function FetchField($fieldOffset = -1) {
$off=$fieldOffset+1; // offsets begin at 1
$o= new ADOFieldObject();
$rs = $this->_queryID;
if (!$rs) return false;
$f = $rs->Fields($fieldOffset);
$o->name = $f->Name;
$t = $f->Type;
@@ -403,8 +425,12 @@ class ADORecordSet_ado extends ADORecordSet {
function _initrs()
{
$rs = $this->_queryID;
$this->_numOfRows = $rs->RecordCount;
try {
$this->_numOfRows = $rs->RecordCount;
} catch (Exception $e) {
$this->_numOfRows = -1;
}
$f = $rs->Fields;
$this->_numOfFields = $f->Count;
}
@@ -618,6 +644,16 @@ class ADORecordSet_ado extends ADORecordSet {
ADOConnection::outp( '<b>'.$f->Name.': currency type not supported by PHP</b>');
$this->fields[] = (float) $f->value;
break;
case 11: //BIT;
$val = "";
if(is_bool($f->value)) {
if($f->value==true) $val = 1;
else $val = 0;
}
if(is_null($f->value)) $val = null;
$this->fields[] = $val;
break;
default:
$this->fields[] = $f->value;
break;
@@ -630,7 +666,7 @@ class ADORecordSet_ado extends ADORecordSet {
@$rs->MoveNext(); // @ needed for some versions of PHP!
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields = &$this->GetRowAssoc(ADODB_ASSOC_CASE);
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
}
return true;
}
@@ -656,7 +692,10 @@ class ADORecordSet_ado extends ADORecordSet {
function _close() {
$this->_flds = false;
try {
@$this->_queryID->Close();// by Pete Dishman (peterd@telephonetics.co.uk)
} catch (Exception $e) {
}
$this->_queryID = false;
}

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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. See License.txt.

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -46,7 +46,7 @@ class ADODB_ado_mssql extends ADODB_ado {
function _insertid()
{
return $this->GetOne('select @@identity');
return $this->GetOne('select SCOPE_IDENTITY()');
}
function _affectedrows()

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -55,7 +55,7 @@ class ADODB_borland_ibase extends ADODB_ibase {
// SELECT col1, col2 FROM TABLE ORDER BY col1 ROWS 3 TO 7 -- first 5 skip 2
// Firebird uses
// SELECT FIRST 5 SKIP 2 col1, col2 FROM TABLE
function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
{
if ($nrows > 0) {
if ($offset <= 0) $str = " ROWS $nrows ";

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -50,7 +50,7 @@ class ADODB_csv extends ADOConnection {
return $this->_affectedrows;
}
function &MetaDatabases()
function MetaDatabases()
{
return false;
}
@@ -72,14 +72,14 @@ class ADODB_csv extends ADOConnection {
return true;
}
function &MetaColumns($table)
function MetaColumns($table)
{
return false;
}
// parameters use PostgreSQL convention, not MySQL
function &SelectLimit($sql,$nrows=-1,$offset=-1)
function SelectLimit($sql,$nrows=-1,$offset=-1)
{
global $ADODB_FETCH_MODE;
@@ -108,13 +108,13 @@ class ADODB_csv extends ADOConnection {
$rs->databaseType='csv';
$rs->fetchMode = ($this->fetchMode !== false) ? $this->fetchMode : $ADODB_FETCH_MODE;
$rs->connection = &$this;
$rs->connection = $this;
}
return $rs;
}
// returns queryID or false
function &_Execute($sql,$inputarr=false)
function _Execute($sql,$inputarr=false)
{
global $ADODB_FETCH_MODE;
@@ -166,7 +166,7 @@ class ADODB_csv extends ADOConnection {
$this->_affectedrows = $rs->affectedrows;
$this->_insertid = $rs->insertid;
$rs->databaseType='csv';
$rs->connection = &$this;
$rs->connection = $this;
}
return $rs;
}

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2006 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.06 16 Oct 2008 (c) 2006 John Lim (jlim#natsoft.com). All rights reserved.
This is a version of the ADODB driver for DB2. It uses the 'ibm_db2' PECL extension
for PHP (http://pecl.php.net/package/ibm_db2), which in turn requires DB2 V8.2.2 or
@@ -33,7 +33,7 @@ class ADODB_db2 extends ADOConnection {
var $sysDate = 'CURRENT DATE';
var $sysTimeStamp = 'CURRENT TIMESTAMP';
var $fmtTimeStamp = "'Y-m-d-H:i:s'";
var $fmtTimeStamp = "'Y-m-d H:i:s'";
var $replaceQuote = "''"; // string to use to replace quotes
var $dataProvider = "db2";
var $hasAffectedRows = true;
@@ -44,7 +44,7 @@ class ADODB_db2 extends ADOConnection {
// breaking backward-compat
var $_bindInputArray = false;
var $_genIDSQL = "VALUES NEXTVAL FOR %s";
var $_genSeqSQL = "CREATE SEQUENCE %s START WITH 1 NO MAXVALUE NO CYCLE";
var $_genSeqSQL = "CREATE SEQUENCE %s START WITH %s NO MAXVALUE NO CYCLE";
var $_dropSeqSQL = "DROP SEQUENCE %s";
var $_autocommit = true;
var $_haserrorfunctions = true;
@@ -68,7 +68,7 @@ class ADODB_db2 extends ADOConnection {
global $php_errormsg;
if (!function_exists('db2_connect')) {
ADOConnection::outp("Warning: The old ODBC based DB2 driver has been renamed 'odbc_db2'. This ADOdb driver calls PHP's native db2 extension.");
ADOConnection::outp("Warning: The old ODBC based DB2 driver has been renamed 'odbc_db2'. This ADOdb driver calls PHP's native db2 extension which is not installed.");
return null;
}
// This needs to be set before the connect().
@@ -228,7 +228,7 @@ class ADODB_db2 extends ADOConnection {
function CreateSequence($seqname='adodbseq',$start=1)
{
if (empty($this->_genSeqSQL)) return false;
$ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname));
$ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname,$start));
if (!$ok) return false;
return true;
}
@@ -249,9 +249,9 @@ class ADODB_db2 extends ADOConnection {
{
// if you have to modify the parameter below, your database is overloaded,
// or you need to implement generation of id's yourself!
$num = $this->GetOne("VALUES NEXTVAL FOR $seq");
$num = $this->GetOne("VALUES NEXTVAL FOR $seq");
return $num;
}
}
function ErrorMsg()
@@ -335,7 +335,7 @@ class ADODB_db2 extends ADOConnection {
if (!$rs) return false;
$arr =& $rs->GetArray();
$arr = $rs->GetArray();
$rs->Close();
$arr2 = array();
for ($i=0; $i < sizeof($arr); $i++) {
@@ -390,7 +390,7 @@ class ADODB_db2 extends ADOConnection {
}
function &MetaTables($ttype=false,$schema=false)
function MetaTables($ttype=false,$schema=false)
{
global $ADODB_FETCH_MODE;
@@ -406,7 +406,7 @@ class ADODB_db2 extends ADOConnection {
return $false;
}
$arr =& $rs->GetArray();
$arr = $rs->GetArray();
$rs->Close();
$arr2 = array();
@@ -495,7 +495,7 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/db2/htm/db2
}
}
function &MetaColumns($table)
function MetaColumns($table)
{
global $ADODB_FETCH_MODE;
@@ -511,7 +511,7 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/db2/htm/db2
$qid = db2_columns($this->_connectionID, "", $schema, $table, $colname);
if (empty($qid)) return $false;
$rs =& new ADORecordSet_db2($qid);
$rs = new ADORecordSet_db2($qid);
$ADODB_FETCH_MODE = $savem;
if (!$rs) return $false;
@@ -563,7 +563,7 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/db2/htm/db2
$qid = db2_primary_keys($this->_connectionID, "", $schema, $table);
if (empty($qid)) return $false;
$rs =& new ADORecordSet_db2($qid);
$rs = new ADORecordSet_db2($qid);
$ADODB_FETCH_MODE = $savem;
if (!$rs) return $retarr;
@@ -719,7 +719,7 @@ class ADORecordSet_db2 extends ADORecordSet {
// returns the field object
function &FetchField($offset = -1)
function FetchField($offset = -1)
{
$o= new ADOFieldObject();
$o->name = @db2_field_name($this->_queryID,$offset);
@@ -761,10 +761,10 @@ class ADORecordSet_db2 extends ADORecordSet {
}
// speed up SelectLimit() by switching to ADODB_FETCH_NUM as ADODB_FETCH_ASSOC is emulated
function &GetArrayLimit($nrows,$offset=-1)
function GetArrayLimit($nrows,$offset=-1)
{
if ($offset <= 0) {
$rs =& $this->GetArray($nrows);
$rs = $this->GetArray($nrows);
return $rs;
}
$savem = $this->fetchMode;
@@ -773,7 +773,7 @@ class ADORecordSet_db2 extends ADORecordSet {
$this->fetchMode = $savem;
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
}
$results = array();
@@ -795,7 +795,7 @@ class ADORecordSet_db2 extends ADORecordSet {
$this->fields = @db2_fetch_array($this->_queryID);
if ($this->fields) {
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
}
return true;
}
@@ -811,7 +811,7 @@ class ADORecordSet_db2 extends ADORecordSet {
$this->fields = db2_fetch_array($this->_queryID);
if ($this->fields) {
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
}
return true;
}

View File

@@ -1,6 +1,6 @@
<?php
/*
@version V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
@version V5.06 16 Oct 2008 (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.
@@ -37,7 +37,7 @@ class ADODB_fbsql extends ADOConnection {
return fbsql_affected_rows($this->_connectionID);
}
function &MetaDatabases()
function MetaDatabases()
{
$qid = fbsql_list_dbs($this->_connectionID);
$arr = array();
@@ -80,7 +80,7 @@ class ADODB_fbsql extends ADOConnection {
return true;
}
function &MetaColumns($table)
function MetaColumns($table)
{
if ($this->metaColumnsSQL) {
@@ -127,7 +127,7 @@ class ADODB_fbsql extends ADOConnection {
// returns queryID or false
function _query($sql,$inputarr)
function _query($sql,$inputarr=false)
{
return fbsql_query("$sql;",$this->_connectionID);
}
@@ -187,7 +187,7 @@ class ADORecordSet_fbsql extends ADORecordSet{
function &FetchField($fieldOffset = -1) {
function FetchField($fieldOffset = -1) {
if ($fieldOffset != -1) {
$o = @fbsql_fetch_field($this->_queryID, $fieldOffset);
//$o->max_length = -1; // fbsql returns the max length less spaces -- so it is unrealiable

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -44,7 +44,7 @@ class ADODB_firebird extends ADODB_ibase {
// Note that Interbase 6.5 uses this ROWS instead - don't you love forking wars!
// SELECT col1, col2 FROM table ROWS 5 -- get 5 rows
// SELECT col1, col2 FROM TABLE ORDER BY col1 ROWS 3 TO 7 -- first 5 skip 2
function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false, $secs=0)
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false, $secs=0)
{
$nrows = (integer) $nrows;
$offset = (integer) $offset;
@@ -54,9 +54,9 @@ class ADODB_firebird extends ADODB_ibase {
$sql = preg_replace('/^[ \t]*select/i',$str,$sql);
if ($secs)
$rs =& $this->CacheExecute($secs,$sql,$inputarr);
$rs = $this->CacheExecute($secs,$sql,$inputarr);
else
$rs =& $this->Execute($sql,$inputarr);
$rs = $this->Execute($sql,$inputarr);
return $rs;
}

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -159,17 +159,17 @@ class ADODB_ibase extends ADOConnection {
// there are some compat problems with ADODB_COUNTRECS=false and $this->_logsql currently.
// it appears that ibase extension cannot support multiple concurrent queryid's
function &_Execute($sql,$inputarr=false)
function _Execute($sql,$inputarr=false)
{
global $ADODB_COUNTRECS;
if ($this->_logsql) {
$savecrecs = $ADODB_COUNTRECS;
$ADODB_COUNTRECS = true; // force countrecs
$ret =& ADOConnection::_Execute($sql,$inputarr);
$ret = ADOConnection::_Execute($sql,$inputarr);
$ADODB_COUNTRECS = $savecrecs;
} else {
$ret =& ADOConnection::_Execute($sql,$inputarr);
$ret = ADOConnection::_Execute($sql,$inputarr);
}
return $ret;
}
@@ -187,7 +187,7 @@ class ADODB_ibase extends ADOConnection {
return $ret;
}
function &MetaIndexes ($table, $primary = FALSE, $owner=false)
function MetaIndexes ($table, $primary = FALSE, $owner=false)
{
// save old fetch mode
global $ADODB_FETCH_MODE;
@@ -326,7 +326,7 @@ class ADODB_ibase extends ADOConnection {
if (is_array($iarr)) {
if (ADODB_PHPVER >= 0x4050) { // actually 4.0.4
if ( !isset($iarr[0]) ) $iarr[0] = ''; // PHP5 compat hack
$fnarr =& array_merge( array($sql) , $iarr);
$fnarr = array_merge( array($sql) , $iarr);
$ret = call_user_func_array($fn,$fnarr);
} else {
switch(sizeof($iarr)) {
@@ -348,7 +348,7 @@ class ADODB_ibase extends ADOConnection {
if (is_array($iarr)) {
if (ADODB_PHPVER >= 0x4050) { // actually 4.0.4
if (sizeof($iarr) == 0) $iarr[0] = ''; // PHP5 compat hack
$fnarr =& array_merge( array($conn,$sql) , $iarr);
$fnarr = array_merge( array($conn,$sql) , $iarr);
$ret = call_user_func_array($fn,$fnarr);
} else {
switch(sizeof($iarr)) {
@@ -476,7 +476,7 @@ class ADODB_ibase extends ADOConnection {
}
//OPN STUFF end
// returns array of ADOFieldObjects for current table
function &MetaColumns($table)
function MetaColumns($table)
{
global $ADODB_FETCH_MODE;
@@ -743,7 +743,7 @@ class ADORecordset_ibase extends ADORecordSet
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. */
function &FetchField($fieldOffset = -1)
function FetchField($fieldOffset = -1)
{
$fld = new ADOFieldObject;
$ibf = ibase_field_info($this->_queryID,$fieldOffset);
@@ -822,9 +822,9 @@ class ADORecordset_ibase extends ADORecordSet
$this->fields = $f;
if ($this->fetchMode == ADODB_FETCH_ASSOC) {
$this->fields = &$this->GetRowAssoc(ADODB_ASSOC_CASE);
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
} else if ($this->fetchMode == ADODB_FETCH_BOTH) {
$this->fields =& array_merge($this->fields,$this->GetRowAssoc(ADODB_ASSOC_CASE));
$this->fields = array_merge($this->fields,$this->GetRowAssoc(ADODB_ASSOC_CASE));
}
return true;
}

View File

@@ -1,6 +1,6 @@
<?php
/**
* @version V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
* @version V5.06 16 Oct 2008 (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.

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim. All rights reserved.
V5.08 6 Apr 2009 (c) 2000-2009 John Lim. 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.
@@ -147,7 +147,7 @@ class ADODB_informix72 extends ADOConnection {
}
function &MetaColumns($table)
function MetaColumns($table)
{
global $ADODB_FETCH_MODE;
@@ -199,7 +199,7 @@ class ADODB_informix72 extends ADOConnection {
return $false;
}
function &xMetaColumns($table)
function xMetaColumns($table)
{
return ADOConnection::MetaColumns($table,false);
}
@@ -219,7 +219,7 @@ class ADODB_informix72 extends ADOConnection {
$rs = $this->Execute($sql);
if (!$rs || $rs->EOF) return false;
$arr =& $rs->GetArray();
$arr = $rs->GetArray();
$a = array();
foreach($arr as $v) {
$coldest=$this->metaColumnNames($v["tabname"]);
@@ -284,7 +284,7 @@ class ADODB_informix72 extends ADOConnection {
}
*/
// returns query ID if successful, otherwise false
function _query($sql,$inputarr)
function _query($sql,$inputarr=false)
{
global $ADODB_COUNTRECS;
@@ -362,7 +362,7 @@ class ADORecordset_informix72 extends ADORecordSet {
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. */
function &FetchField($fieldOffset = -1)
function FetchField($fieldOffset = -1)
{
if (empty($this->_fieldprops)) {
$fp = ifx_fieldproperties($this->_queryID);

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -40,6 +40,9 @@ class ADODB_ldap extends ADOConnection {
# Options configuration information
var $LDAP_CONNECT_OPTIONS;
# error on binding, eg. "Binding: invalid credentials"
var $_bind_errmsg = "Binding: %s";
function ADODB_ldap()
{
}
@@ -52,13 +55,17 @@ class ADODB_ldap extends ADOConnection {
if ( !function_exists( 'ldap_connect' ) ) return null;
$conn_info = array( $host,$this->port);
if (strpos('ldap://',$host) === 0 || strpos('ldaps://',$host) === 0) {
$this->_connectionID = @ldap_connect($host);
} else {
$conn_info = array( $host,$this->port);
if ( strstr( $host, ':' ) ) {
$conn_info = split( ':', $host );
}
if ( strstr( $host, ':' ) ) {
$conn_info = split( ':', $host );
}
$this->_connectionID = ldap_connect( $conn_info[0], $conn_info[1] );
$this->_connectionID = @ldap_connect( $conn_info[0], $conn_info[1] );
}
if (!$this->_connectionID) {
$e = 'Could not connect to ' . $conn_info[0];
$this->_errorMsg = $e;
@@ -70,14 +77,14 @@ class ADODB_ldap extends ADOConnection {
}
if ($username) {
$bind = ldap_bind( $this->_connectionID, $username, $password );
$bind = @ldap_bind( $this->_connectionID, $username, $password );
} else {
$username = 'anonymous';
$bind = ldap_bind( $this->_connectionID );
$bind = @ldap_bind( $this->_connectionID );
}
if (!$bind) {
$e = 'Could not bind to ' . $conn_info[0] . " as ".$username;
$e = sprintf($this->_bind_errmsg,ldap_error($this->_connectionID));
$this->_errorMsg = $e;
if ($this->debug) ADOConnection::outp($e);
return false;
@@ -147,13 +154,23 @@ class ADODB_ldap extends ADOConnection {
}
/* returns _queryID or false */
function _query($sql,$inputarr)
function _query($sql,$inputarr=false)
{
$rs = ldap_search( $this->_connectionID, $this->database, $sql );
$this->_errorMsg = ($rs) ? '' : 'Search error on '.$sql;
$rs = @ldap_search( $this->_connectionID, $this->database, $sql );
$this->_errorMsg = ($rs) ? '' : 'Search error on '.$sql.': '.ldap_error($this->_connectionID);
return $rs;
}
function ErrorMsg()
{
return $this->_errorMsg;
}
function ErrorNo()
{
return @ldap_errno($this->_connectionID);
}
/* closes the LDAP connection */
function _close()
{
@@ -311,7 +328,7 @@ class ADORecordSet_ldap extends ADORecordSet{
/*
Return whole recordset as a multi-dimensional associative array
*/
function &GetAssoc($force_array = false, $first2cols = false)
function GetAssoc($force_array = false, $first2cols = false)
{
$records = $this->_numOfRows;
$results = array();
@@ -331,7 +348,7 @@ class ADORecordSet_ldap extends ADORecordSet{
return $results;
}
function &GetRowAssoc()
function GetRowAssoc()
{
$results = array();
foreach ( $this->fields as $k=>$v ) {

File diff suppressed because it is too large Load Diff

View File

@@ -1,166 +1,171 @@
<?php
/// $Id $
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// ADOdb - Database Abstraction Library for PHP //
// http://adodb.sourceforge.net/ //
// //
// Copyright (C) 2000-2007 John Lim (jlim\@natsoft.com.my) //
// All rights reserved. //
// Released under both BSD license and LGPL library license. //
// Whenever there is any discrepancy between the two licenses, //
// the BSD license will take precedence //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
// Copyright (C) 2001-3001 Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
/**
* MSSQL Driver with auto-prepended "N" for correct unicode storage
* of SQL literal strings. Intended to be used with MSSQL drivers that
* are sending UCS-2 data to MSSQL (FreeTDS and ODBTP) in order to get
* true cross-db compatibility from the application point of view.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
// one useful constant
if (!defined('SINGLEQUOTE')) define('SINGLEQUOTE', "'");
include_once(ADODB_DIR.'/drivers/adodb-mssql.inc.php');
class ADODB_mssql_n extends ADODB_mssql {
var $databaseType = "mssql_n";
function ADODB_mssqlpo()
{
ADODB_mssql::ADODB_mssql();
}
function _query($sql,$inputarr)
{
$sql = $this->_appendN($sql);
return ADODB_mssql::_query($sql,$inputarr);
}
/**
* This function will intercept all the literals used in the SQL, prepending the "N" char to them
* in order to allow mssql to store properly data sent in the correct UCS-2 encoding (by freeTDS
* and ODBTP) keeping SQL compatibility at ADOdb level (instead of hacking every project to add
* the "N" notation when working against MSSQL.
*
* Note that this hack only must be used if ALL the char-based columns in your DB are of type nchar,
* nvarchar and ntext
*/
function _appendN($sql) {
$result = $sql;
/// Check we have some single quote in the query. Exit ok.
if (strpos($sql, SINGLEQUOTE) === false) {
return $sql;
}
/// Check we haven't an odd number of single quotes (this can cause problems below
/// and should be considered one wrong SQL). Exit with debug info.
if ((substr_count($sql, SINGLEQUOTE) & 1)) {
if ($this->debug) {
ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Wrong number of quotes (odd)");
}
return $sql;
}
/// Check we haven't any backslash + single quote combination. It should mean wrong
/// backslashes use (bad magic_quotes_sybase?). Exit with debug info.
$regexp = '/(\\\\' . SINGLEQUOTE . '[^' . SINGLEQUOTE . '])/';
if (preg_match($regexp, $sql)) {
if ($this->debug) {
ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Found bad use of backslash + single quote");
}
return $sql;
}
/// Remove pairs of single-quotes
$pairs = array();
$regexp = '/(' . SINGLEQUOTE . SINGLEQUOTE . ')/';
preg_match_all($regexp, $result, $list_of_pairs);
if ($list_of_pairs) {
foreach (array_unique($list_of_pairs[0]) as $key=>$value) {
$pairs['<@#@#@PAIR-'.$key.'@#@#@>'] = $value;
}
if (!empty($pairs)) {
$result = str_replace($pairs, array_keys($pairs), $result);
}
}
/// Remove the rest of literals present in the query
$literals = array();
$regexp = '/(N?' . SINGLEQUOTE . '.*?' . SINGLEQUOTE . ')/is';
preg_match_all($regexp, $result, $list_of_literals);
if ($list_of_literals) {
foreach (array_unique($list_of_literals[0]) as $key=>$value) {
$literals['<#@#@#LITERAL-'.$key.'#@#@#>'] = $value;
}
if (!empty($literals)) {
$result = str_replace($literals, array_keys($literals), $result);
}
}
/// Analyse literals to prepend the N char to them if their contents aren't numeric
if (!empty($literals)) {
foreach ($literals as $key=>$value) {
if (!is_numeric(trim($value, SINGLEQUOTE))) {
/// Non numeric string, prepend our dear N
$literals[$key] = 'N' . trim($value, 'N'); //Trimming potentially existing previous "N"
}
}
}
/// Re-apply literals to the text
if (!empty($literals)) {
$result = str_replace(array_keys($literals), $literals, $result);
}
/// Re-apply pairs of single-quotes to the text
if (!empty($pairs)) {
$result = str_replace(array_keys($pairs), $pairs, $result);
}
/// Print transformation if debug = on
if ($result != $sql && $this->debug) {
ADOConnection::outp("{$this->databaseType} internal transformation:<br>{$sql}<br>to<br>{$result}");
}
return $result;
}
}
class ADORecordset_mssql_n extends ADORecordset_mssql {
var $databaseType = "mssql_n";
function ADORecordset_mssql_n($id,$mode=false)
{
$this->ADORecordset_mssql($id,$mode);
}
}
<?php
/// $Id $
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// ADOdb - Database Abstraction Library for PHP //
// http://adodb.sourceforge.net/ //
// //
// Copyright (C) 2000-2009 John Lim (jlim\@natsoft.com.my) //
// All rights reserved. //
// Released under both BSD license and LGPL library license. //
// Whenever there is any discrepancy between the two licenses, //
// the BSD license will take precedence //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
// Copyright (C) 2001-3001 Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
/**
* MSSQL Driver with auto-prepended "N" for correct unicode storage
* of SQL literal strings. Intended to be used with MSSQL drivers that
* are sending UCS-2 data to MSSQL (FreeTDS and ODBTP) in order to get
* true cross-db compatibility from the application point of view.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
// one useful constant
if (!defined('SINGLEQUOTE')) define('SINGLEQUOTE', "'");
include_once(ADODB_DIR.'/drivers/adodb-mssql.inc.php');
class ADODB_mssql_n extends ADODB_mssql {
var $databaseType = "mssql_n";
function ADODB_mssqlpo()
{
ADODB_mssql::ADODB_mssql();
}
function _query($sql,$inputarr=false)
{
$sql = $this->_appendN($sql);
return ADODB_mssql::_query($sql,$inputarr);
}
/**
* This function will intercept all the literals used in the SQL, prepending the "N" char to them
* in order to allow mssql to store properly data sent in the correct UCS-2 encoding (by freeTDS
* and ODBTP) keeping SQL compatibility at ADOdb level (instead of hacking every project to add
* the "N" notation when working against MSSQL.
*
* Note that this hack only must be used if ALL the char-based columns in your DB are of type nchar,
* nvarchar and ntext
*/
function _appendN($sql) {
$result = $sql;
/// Check we have some single quote in the query. Exit ok.
if (strpos($sql, SINGLEQUOTE) === false) {
return $sql;
}
/// Check we haven't an odd number of single quotes (this can cause problems below
/// and should be considered one wrong SQL). Exit with debug info.
if ((substr_count($sql, SINGLEQUOTE) & 1)) {
if ($this->debug) {
ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Wrong number of quotes (odd)");
}
return $sql;
}
/// Check we haven't any backslash + single quote combination. It should mean wrong
/// backslashes use (bad magic_quotes_sybase?). Exit with debug info.
$regexp = '/(\\\\' . SINGLEQUOTE . '[^' . SINGLEQUOTE . '])/';
if (preg_match($regexp, $sql)) {
if ($this->debug) {
ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Found bad use of backslash + single quote");
}
return $sql;
}
/// Remove pairs of single-quotes
$pairs = array();
$regexp = '/(' . SINGLEQUOTE . SINGLEQUOTE . ')/';
preg_match_all($regexp, $result, $list_of_pairs);
if ($list_of_pairs) {
foreach (array_unique($list_of_pairs[0]) as $key=>$value) {
$pairs['<@#@#@PAIR-'.$key.'@#@#@>'] = $value;
}
if (!empty($pairs)) {
$result = str_replace($pairs, array_keys($pairs), $result);
}
}
/// Remove the rest of literals present in the query
$literals = array();
$regexp = '/(N?' . SINGLEQUOTE . '.*?' . SINGLEQUOTE . ')/is';
preg_match_all($regexp, $result, $list_of_literals);
if ($list_of_literals) {
foreach (array_unique($list_of_literals[0]) as $key=>$value) {
$literals['<#@#@#LITERAL-'.$key.'#@#@#>'] = $value;
}
if (!empty($literals)) {
$result = str_replace($literals, array_keys($literals), $result);
}
}
/// Analyse literals to prepend the N char to them if their contents aren't numeric
if (!empty($literals)) {
foreach ($literals as $key=>$value) {
if (!is_numeric(trim($value, SINGLEQUOTE))) {
/// Non numeric string, prepend our dear N
$literals[$key] = 'N' . trim($value, 'N'); //Trimming potentially existing previous "N"
}
}
}
/// Re-apply literals to the text
if (!empty($literals)) {
$result = str_replace(array_keys($literals), $literals, $result);
}
/// Any pairs followed by N' must be switched to N' followed by those pairs
/// (or strings beginning with single quotes will fail)
$result = preg_replace("/((<@#@#@PAIR-(\d+)@#@#@>)+)N'/", "N'$1", $result);
/// Re-apply pairs of single-quotes to the text
if (!empty($pairs)) {
$result = str_replace(array_keys($pairs), $pairs, $result);
}
/// Print transformation if debug = on
if ($result != $sql && $this->debug) {
ADOConnection::outp("{$this->databaseType} internal transformation:<br>{$sql}<br>to<br>{$result}");
}
return $result;
}
}
class ADORecordset_mssql_n extends ADORecordset_mssql {
var $databaseType = "mssql_n";
function ADORecordset_mssql_n($id,$mode=false)
{
$this->ADORecordset_mssql($id,$mode);
}
}
?>

View File

@@ -0,0 +1,922 @@
<?php
/*
V5.08 6 Apr 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.
Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net
Native mssql driver. Requires mssql client. Works on Windows.
http://www.microsoft.com/sql/technologies/php/default.mspx
To configure for Unix, see
http://phpbuilder.com/columns/alberto20000919.php3
$stream = sqlsrv_get_field($stmt, $index, SQLSRV_SQLTYPE_STREAM(SQLSRV_ENC_BINARY));
stream_filter_append($stream, "convert.iconv.ucs-2/utf-8"); // Voila, UTF-8 can be read directly from $stream
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
if (!function_exists('sqlsrv_configure')) {
die("mssqlnative extension not installed");
}
if (!function_exists('sqlsrv_set_error_handling')) {
function sqlsrv_set_error_handling($constant) {
sqlsrv_configure("WarningsReturnAsErrors", $constant);
}
}
if (!function_exists('sqlsrv_log_set_severity')) {
function sqlsrv_log_set_severity($constant) {
sqlsrv_configure("LogSeverity", $constant);
}
}
if (!function_exists('sqlsrv_log_set_subsystems')) {
function sqlsrv_log_set_subsystems($constant) {
sqlsrv_configure("LogSubsystems", $constant);
}
}
//----------------------------------------------------------------
// MSSQL returns dates with the format Oct 13 2002 or 13 Oct 2002
// and this causes tons of problems because localized versions of
// MSSQL will return the dates in dmy or mdy order; and also the
// month strings depends on what language has been configured. The
// following two variables allow you to control the localization
// settings - Ugh.
//
// MORE LOCALIZATION INFO
// ----------------------
// To configure datetime, look for and modify sqlcommn.loc,
// typically found in c:\mssql\install
// Also read :
// http://support.microsoft.com/default.aspx?scid=kb;EN-US;q220918
// Alternatively use:
// CONVERT(char(12),datecol,120)
//
// Also if your month is showing as month-1,
// e.g. Jan 13, 2002 is showing as 13/0/2002, then see
// http://phplens.com/lens/lensforum/msgs.php?id=7048&x=1
// it's a localisation problem.
//----------------------------------------------------------------
// has datetime converstion to YYYY-MM-DD format, and also mssql_fetch_assoc
if (ADODB_PHPVER >= 0x4300) {
// docs say 4.2.0, but testing shows only since 4.3.0 does it work!
ini_set('mssql.datetimeconvert',0);
} else {
global $ADODB_mssql_mths; // array, months must be upper-case
$ADODB_mssql_date_order = 'mdy';
$ADODB_mssql_mths = array(
'JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6,
'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12);
}
//---------------------------------------------------------------------------
// Call this to autoset $ADODB_mssql_date_order at the beginning of your code,
// just after you connect to the database. Supports mdy and dmy only.
// Not required for PHP 4.2.0 and above.
function AutoDetect_MSSQL_Date_Order($conn)
{
global $ADODB_mssql_date_order;
$adate = $conn->GetOne('select getdate()');
if ($adate) {
$anum = (int) $adate;
if ($anum > 0) {
if ($anum > 31) {
//ADOConnection::outp( "MSSQL: YYYY-MM-DD date format not supported currently");
} else
$ADODB_mssql_date_order = 'dmy';
} else
$ADODB_mssql_date_order = 'mdy';
}
}
class ADODB_mssqlnative extends ADOConnection {
var $databaseType = "mssqlnative";
var $dataProvider = "mssqlnative";
var $replaceQuote = "''"; // string to use to replace quotes
var $fmtDate = "'Y-m-d'";
var $fmtTimeStamp = "'Y-m-d H:i:s'";
var $hasInsertID = true;
var $substr = "substring";
var $length = 'len';
var $hasAffectedRows = true;
var $poorAffectedRows = false;
var $metaDatabasesSQL = "select name from sys.sysdatabases where name <> 'master'";
var $metaTablesSQL="select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE','dtproperties'))";
var $metaColumnsSQL = # xtype==61 is datetime
"select c.name,t.name,c.length,
(case when c.xusertype=61 then 0 else c.xprec end),
(case when c.xusertype=61 then 0 else c.xscale end)
from syscolumns c join systypes t on t.xusertype=c.xusertype join sysobjects o on o.id=c.id where o.name='%s'";
var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE
var $hasGenID = true;
var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)';
var $sysTimeStamp = 'GetDate()';
var $maxParameterLen = 4000;
var $arrayClass = 'ADORecordSet_array_mssqlnative';
var $uniqueSort = true;
var $leftOuter = '*=';
var $rightOuter = '=*';
var $ansiOuter = true; // for mssql7 or later
var $identitySQL = 'select SCOPE_IDENTITY()'; // 'select SCOPE_IDENTITY'; # for mssql 2000
var $uniqueOrderBy = true;
var $_bindInputArray = true;
var $_dropSeqSQL = "drop table %s";
function ADODB_mssqlnative()
{
if ($this->debug) {
error_log("<pre>");
sqlsrv_set_error_handling( SQLSRV_ERRORS_LOG_ALL );
sqlsrv_log_set_severity( SQLSRV_LOG_SEVERITY_ALL );
sqlsrv_log_set_subsystems(SQLSRV_LOG_SYSTEM_ALL);
sqlsrv_configure('warnings_return_as_errors', 0);
} else {
sqlsrv_set_error_handling(0);
sqlsrv_log_set_severity(0);
sqlsrv_log_set_subsystems(SQLSRV_LOG_SYSTEM_ALL);
sqlsrv_configure('warnings_return_as_errors', 0);
}
}
function ServerInfo()
{
global $ADODB_FETCH_MODE;
if ($this->fetchMode === false) {
$savem = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
} else
$savem = $this->SetFetchMode(ADODB_FETCH_NUM);
$arrServerInfo = sqlsrv_server_info($this->_connectionID);
$arr['description'] = $arrServerInfo['SQLServerName'].' connected to '.$arrServerInfo['CurrentDatabase'];
$arr['version'] = $arrServerInfo['SQLServerVersion'];//ADOConnection::_findvers($arr['description']);
return $arr;
}
function IfNull( $field, $ifNull )
{
return " ISNULL($field, $ifNull) "; // if MS SQL Server
}
function _insertid()
{
// SCOPE_IDENTITY()
// Returns the last IDENTITY value inserted into an IDENTITY column in
// the same scope. A scope is a module -- a stored procedure, trigger,
// function, or batch. Thus, two statements are in the same scope if
// they are in the same stored procedure, function, or batch.
return $this->GetOne($this->identitySQL);
}
function _affectedrows()
{
return sqlsrv_rows_affected($this->_queryID);
}
function CreateSequence($seq='adodbseq',$start=1)
{
if($this->debug) error_log("<hr>CreateSequence($seq,$start)");
sqlsrv_begin_transaction($this->_connectionID);
$start -= 1;
$this->Execute("create table $seq (id int)");//was float(53)
$ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)");
if (!$ok) {
if($this->debug) error_log("<hr>Error: ROLLBACK");
sqlsrv_rollback($this->_connectionID);
return false;
}
sqlsrv_commit($this->_connectionID);
return true;
}
function GenID($seq='adodbseq',$start=1)
{
if($this->debug) error_log("<hr>GenID($seq,$start)");
sqlsrv_begin_transaction($this->_connectionID);
$ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1");
if (!$ok) {
$this->Execute("create table $seq (id int)");
$ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)");
if (!$ok) {
if($this->debug) error_log("<hr>Error: ROLLBACK");
sqlsrv_rollback($this->_connectionID);
return false;
}
sqlsrv_commit($this->_connectionID);
return $start;
}
$num = $this->GetOne("select id from $seq");
sqlsrv_commit($this->_connectionID);
if($this->debug) error_log(" Returning: $num");
return $num;
}
// Format date column in sql string given an input format that understands Y M D
function SQLDate($fmt, $col=false)
{
if (!$col) $col = $this->sysTimeStamp;
$s = '';
$len = strlen($fmt);
for ($i=0; $i < $len; $i++) {
if ($s) $s .= '+';
$ch = $fmt[$i];
switch($ch) {
case 'Y':
case 'y':
$s .= "datename(yyyy,$col)";
break;
case 'M':
$s .= "convert(char(3),$col,0)";
break;
case 'm':
$s .= "replace(str(month($col),2),' ','0')";
break;
case 'Q':
case 'q':
$s .= "datename(quarter,$col)";
break;
case 'D':
case 'd':
$s .= "replace(str(day($col),2),' ','0')";
break;
case 'h':
$s .= "substring(convert(char(14),$col,0),13,2)";
break;
case 'H':
$s .= "replace(str(datepart(hh,$col),2),' ','0')";
break;
case 'i':
$s .= "replace(str(datepart(mi,$col),2),' ','0')";
break;
case 's':
$s .= "replace(str(datepart(ss,$col),2),' ','0')";
break;
case 'a':
case 'A':
$s .= "substring(convert(char(19),$col,0),18,2)";
break;
default:
if ($ch == '\\') {
$i++;
$ch = substr($fmt,$i,1);
}
$s .= $this->qstr($ch);
break;
}
}
return $s;
}
function BeginTrans()
{
if ($this->transOff) return true;
$this->transCnt += 1;
if ($this->debug) error_log('<hr>begin transaction');
sqlsrv_begin_transaction($this->_connectionID);
return true;
}
function CommitTrans($ok=true)
{
if ($this->transOff) return true;
if ($this->debug) error_log('<hr>commit transaction');
if (!$ok) return $this->RollbackTrans();
if ($this->transCnt) $this->transCnt -= 1;
sqlsrv_commit($this->_connectionID);
return true;
}
function RollbackTrans()
{
if ($this->transOff) return true;
if ($this->debug) error_log('<hr>rollback transaction');
if ($this->transCnt) $this->transCnt -= 1;
sqlsrv_rollback($this->_connectionID);
return true;
}
function SetTransactionMode( $transaction_mode )
{
$this->_transmode = $transaction_mode;
if (empty($transaction_mode)) {
$this->Execute('SET TRANSACTION ISOLATION LEVEL READ COMMITTED');
return;
}
if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode;
$this->Execute("SET TRANSACTION ".$transaction_mode);
}
/*
Usage:
$this->BeginTrans();
$this->RowLock('table1,table2','table1.id=33 and table2.id=table1.id'); # lock row 33 for both tables
# some operation on both tables table1 and table2
$this->CommitTrans();
See http://www.swynk.com/friends/achigrik/SQL70Locks.asp
*/
function RowLock($tables,$where,$flds='top 1 null as ignore')
{
if (!$this->transCnt) $this->BeginTrans();
return $this->GetOne("select $flds from $tables with (ROWLOCK,HOLDLOCK) where $where");
}
function SelectDB($dbName)
{
$this->database = $dbName;
$this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions
if ($this->_connectionID) {
$rs = $this->Execute('USE '.$dbName);
if($rs) {
return true;
} else return false;
}
else return false;
}
function ErrorMsg()
{
$retErrors = sqlsrv_errors(SQLSRV_ERR_ALL);
if($retErrors != null) {
foreach($retErrors as $arrError) {
$this->_errorMsg .= "SQLState: ".$arrError[ 'SQLSTATE']."\n";
$this->_errorMsg .= "Error Code: ".$arrError[ 'code']."\n";
$this->_errorMsg .= "Message: ".$arrError[ 'message']."\n";
}
} else {
$this->_errorMsg = "No errors found";
}
return $this->_errorMsg;
}
function ErrorNo()
{
if ($this->_logsql && $this->_errorCode !== false) return $this->_errorCode;
$err = sqlsrv_errors(SQLSRV_ERR_ALL);
if($err[0]) return $err[0]['code'];
else return -1;
}
// returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if (!function_exists('sqlsrv_connect')) return null;
$connectionInfo = array("Database"=>$argDatabasename,'UID'=>$argUsername,'PWD'=>$argPassword);
if ($this->debug) error_log("<hr>connecting... hostname: $argHostname params: ".var_export($connectionInfo,true));
//if ($this->debug) error_log("<hr>_connectionID before: ".serialize($this->_connectionID));
if(!($this->_connectionID = sqlsrv_connect($argHostname,$connectionInfo))) {
if ($this->debug) error_log( "<hr><b>errors</b>: ".print_r( sqlsrv_errors(), true));
return false;
}
//if ($this->debug) error_log(" _connectionID after: ".serialize($this->_connectionID));
//if ($this->debug) error_log("<hr>defined functions: <pre>".var_export(get_defined_functions(),true)."</pre>");
return true;
}
// returns true or false
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
//return null;//not implemented. NOTE: Persistent connections have no effect if PHP is used as a CGI program. (FastCGI!)
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
}
function Prepare($sql)
{
$stmt = sqlsrv_prepare( $this->_connectionID, $sql);
if (!$stmt) return $sql;
return array($sql,$stmt);
}
// returns concatenated string
// MSSQL requires integers to be cast as strings
// automatically cast every datatype to VARCHAR(255)
// @author David Rogers (introspectshun)
function Concat()
{
$s = "";
$arr = func_get_args();
// Split single record on commas, if possible
if (sizeof($arr) == 1) {
foreach ($arr as $arg) {
$args = explode(',', $arg);
}
$arr = $args;
}
array_walk($arr, create_function('&$v', '$v = "CAST(" . $v . " AS VARCHAR(255))";'));
$s = implode('+',$arr);
if (sizeof($arr) > 0) return "$s";
return '';
}
/*
Unfortunately, it appears that mssql cannot handle varbinary > 255 chars
So all your blobs must be of type "image".
Remember to set in php.ini the following...
; Valid range 0 - 2147483647. Default = 4096.
mssql.textlimit = 0 ; zero to pass through
; Valid range 0 - 2147483647. Default = 4096.
mssql.textsize = 0 ; zero to pass through
*/
function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
{
if (strtoupper($blobtype) == 'CLOB') {
$sql = "UPDATE $table SET $column='" . $val . "' WHERE $where";
return $this->Execute($sql) != false;
}
$sql = "UPDATE $table SET $column=0x".bin2hex($val)." WHERE $where";
return $this->Execute($sql) != false;
}
// returns query ID if successful, otherwise false
function _query($sql,$inputarr=false)
{
$this->_errorMsg = false;
if (is_array($inputarr)) {
$rez = sqlsrv_query($this->_connectionID,$sql,$inputarr);
} else if (is_array($sql)) {
$rez = sqlsrv_query($this->_connectionID,$sql[1],$inputarr);
} else {
$rez = sqlsrv_query($this->_connectionID,$sql);
}
if ($this->debug) error_log("<hr>running query: ".var_export($sql,true)."<hr>input array: ".var_export($inputarr,true)."<hr>result: ".var_export($rez,true));//"<hr>connection: ".serialize($this->_connectionID)
//fix for returning true on anything besides select statements
if (is_array($sql)) $sql = $sql[1];
$sql = ltrim($sql);
if(stripos($sql, 'SELECT') !== 0 && $rez !== false) {
if ($this->debug) error_log(" isn't a select query, returning boolean true");
return true;
}
//end fix
if(!$rez) $rez = false;
return $rez;
}
// returns true or false
function _close()
{
if ($this->transCnt) $this->RollbackTrans();
$rez = @sqlsrv_close($this->_connectionID);
$this->_connectionID = false;
return $rez;
}
// mssql uses a default date like Dec 30 2000 12:00AM
static function UnixDate($v)
{
return ADORecordSet_array_mssql::UnixDate($v);
}
static function UnixTimeStamp($v)
{
return ADORecordSet_array_mssql::UnixTimeStamp($v);
}
function &MetaIndexes($table,$primary=false)
{
$table = $this->qstr($table);
$sql = "SELECT i.name AS ind_name, C.name AS col_name, USER_NAME(O.uid) AS Owner, c.colid, k.Keyno,
CASE WHEN I.indid BETWEEN 1 AND 254 AND (I.status & 2048 = 2048 OR I.Status = 16402 AND O.XType = 'V') THEN 1 ELSE 0 END AS IsPK,
CASE WHEN I.status & 2 = 2 THEN 1 ELSE 0 END AS IsUnique
FROM dbo.sysobjects o INNER JOIN dbo.sysindexes I ON o.id = i.id
INNER JOIN dbo.sysindexkeys K ON I.id = K.id AND I.Indid = K.Indid
INNER JOIN dbo.syscolumns c ON K.id = C.id AND K.colid = C.Colid
WHERE LEFT(i.name, 8) <> '_WA_Sys_' AND o.status >= 0 AND O.Name LIKE $table
ORDER BY O.name, I.Name, K.keyno";
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== FALSE) {
$savem = $this->SetFetchMode(FALSE);
}
$rs = $this->Execute($sql);
if (isset($savem)) {
$this->SetFetchMode($savem);
}
$ADODB_FETCH_MODE = $save;
if (!is_object($rs)) {
return FALSE;
}
$indexes = array();
while ($row = $rs->FetchRow()) {
if (!$primary && $row[5]) continue;
$indexes[$row[0]]['unique'] = $row[6];
$indexes[$row[0]]['columns'][] = $row[1];
}
return $indexes;
}
function MetaForeignKeys($table, $owner=false, $upper=false)
{
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$table = $this->qstr(strtoupper($table));
$sql =
"select object_name(constid) as constraint_name,
col_name(fkeyid, fkey) as column_name,
object_name(rkeyid) as referenced_table_name,
col_name(rkeyid, rkey) as referenced_column_name
from sysforeignkeys
where upper(object_name(fkeyid)) = $table
order by constraint_name, referenced_table_name, keyno";
$constraints =& $this->GetArray($sql);
$ADODB_FETCH_MODE = $save;
$arr = false;
foreach($constraints as $constr) {
//print_r($constr);
$arr[$constr[0]][$constr[2]][] = $constr[1].'='.$constr[3];
}
if (!$arr) return false;
$arr2 = false;
foreach($arr as $k => $v) {
foreach($v as $a => $b) {
if ($upper) $a = strtoupper($a);
$arr2[$a] = $b;
}
}
return $arr2;
}
//From: Fernando Moreira <FMoreira@imediata.pt>
function MetaDatabases()
{
$this->SelectDB("master");
$rs =& $this->Execute($this->metaDatabasesSQL);
$rows = $rs->GetRows();
$ret = array();
for($i=0;$i<count($rows);$i++) {
$ret[] = $rows[$i][0];
}
$this->SelectDB($this->database);
if($ret)
return $ret;
else
return false;
}
// "Stein-Aksel Basma" <basma@accelero.no>
// tested with MSSQL 2000
function &MetaPrimaryKeys($table)
{
global $ADODB_FETCH_MODE;
$schema = '';
$this->_findschema($table,$schema);
if (!$schema) $schema = $this->database;
if ($schema) $schema = "and k.table_catalog like '$schema%'";
$sql = "select distinct k.column_name,ordinal_position from information_schema.key_column_usage k,
information_schema.table_constraints tc
where tc.constraint_name = k.constraint_name and tc.constraint_type =
'PRIMARY KEY' and k.table_name = '$table' $schema order by ordinal_position ";
$savem = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$a = $this->GetCol($sql);
$ADODB_FETCH_MODE = $savem;
if ($a && sizeof($a)>0) return $a;
$false = false;
return $false;
}
function &MetaTables($ttype=false,$showSchema=false,$mask=false)
{
if ($mask) {
$save = $this->metaTablesSQL;
$mask = $this->qstr(($mask));
$this->metaTablesSQL .= " AND name like $mask";
}
$ret =& ADOConnection::MetaTables($ttype,$showSchema);
if ($mask) {
$this->metaTablesSQL = $save;
}
return $ret;
}
}
/*--------------------------------------------------------------------------------------
Class Name: Recordset
--------------------------------------------------------------------------------------*/
class ADORecordset_mssqlnative extends ADORecordSet {
var $databaseType = "mssqlnative";
var $canSeek = false;
var $fieldOffset = 0;
// _mths works only in non-localised system
function ADORecordset_mssqlnative($id,$mode=false)
{
if ($mode === false) {
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
}
$this->fetchMode = $mode;
return $this->ADORecordSet($id,$mode);
}
function _initrs()
{
global $ADODB_COUNTRECS;
if ($this->connection->debug) error_log("(before) ADODB_COUNTRECS: {$ADODB_COUNTRECS} _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}");
/*$retRowsAff = sqlsrv_rows_affected($this->_queryID);//"If you need to determine the number of rows a query will return before retrieving the actual results, appending a SELECT COUNT ... query would let you get that information, and then a call to next_result would move you to the "real" results."
error_log("rowsaff: ".serialize($retRowsAff));
$this->_numOfRows = ($ADODB_COUNTRECS)? $retRowsAff:-1;*/
$this->_numOfRows = -1;//not supported
$fieldmeta = sqlsrv_field_metadata($this->_queryID);
$this->_numOfFields = ($fieldmeta)? count($fieldmeta):-1;
if ($this->connection->debug) error_log("(after) _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}");
}
//Contributed by "Sven Axelsson" <sven.axelsson@bokochwebb.se>
// get next resultset - requires PHP 4.0.5 or later
function NextRecordSet()
{
if (!sqlsrv_next_result($this->_queryID)) return false;
$this->_inited = false;
$this->bind = false;
$this->_currentRow = -1;
$this->Init();
return true;
}
/* Use associative array to get fields array */
function Fields($colname)
{
if ($this->fetchMode != ADODB_FETCH_NUM) return $this->fields[$colname];
if (!$this->bind) {
$this->bind = array();
for ($i=0; $i < $this->_numOfFields; $i++) {
$o = $this->FetchField($i);
$this->bind[strtoupper($o->name)] = $i;
}
}
return $this->fields[$this->bind[strtoupper($colname)]];
}
/* 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. */
function &FetchField($fieldOffset = -1)
{
if ($this->connection->debug) error_log("<hr>fetchfield: $fieldOffset, fetch array: <pre>".print_r($this->fields,true)."</pre> backtrace: ".adodb_backtrace(false));
if ($fieldOffset != -1) $this->fieldOffset = $fieldOffset;
$arrKeys = array_keys($this->fields);
if(array_key_exists($this->fieldOffset,$arrKeys) && !array_key_exists($arrKeys[$this->fieldOffset],$this->fields)) {
$f = false;
} else {
$f = $this->fields[ $arrKeys[$this->fieldOffset] ];
if($fieldOffset == -1) $this->fieldOffset++;
}
if (empty($f)) {
$f = false;//PHP Notice: Only variable references should be returned by reference
}
return $f;
}
function _seek($row)
{
return false;//There is no support for cursors in the driver at this time. All data is returned via forward-only streams.
}
// speedup
function MoveNext()
{
if ($this->connection->debug) error_log("movenext()");
//if ($this->connection->debug) error_log("eof (beginning): ".$this->EOF);
if ($this->EOF) return false;
$this->_currentRow++;
if ($this->connection->debug) error_log("_currentRow: ".$this->_currentRow);
if ($this->_fetch()) return true;
$this->EOF = true;
//if ($this->connection->debug) error_log("eof (end): ".$this->EOF);
return false;
}
// INSERT UPDATE DELETE returns false even if no error occurs in 4.0.4
// also the date format has been changed from YYYY-mm-dd to dd MMM YYYY in 4.0.4. Idiot!
function _fetch($ignore_fields=false)
{
if ($this->connection->debug) error_log("_fetch()");
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
if ($this->fetchMode & ADODB_FETCH_NUM) {
if ($this->connection->debug) error_log("fetch mode: both");
$this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_BOTH);
} else {
if ($this->connection->debug) error_log("fetch mode: assoc");
$this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_ASSOC);
}
if (ADODB_ASSOC_CASE == 0) {
foreach($this->fields as $k=>$v) {
$this->fields[strtolower($k)] = $v;
}
} else if (ADODB_ASSOC_CASE == 1) {
foreach($this->fields as $k=>$v) {
$this->fields[strtoupper($k)] = $v;
}
}
} else {
if ($this->connection->debug) error_log("fetch mode: num");
$this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_NUMERIC);
}
if(is_array($this->fields) && array_key_exists(1,$this->fields) && !array_key_exists(0,$this->fields)) {//fix fetch numeric keys since they're not 0 based
$arrFixed = array();
foreach($this->fields as $key=>$value) {
if(is_numeric($key)) {
$arrFixed[$key-1] = $value;
} else {
$arrFixed[$key] = $value;
}
}
//if($this->connection->debug) error_log("<hr>fixing non 0 based return array, old: ".print_r($this->fields,true)." new: ".print_r($arrFixed,true));
$this->fields = $arrFixed;
}
if(is_array($this->fields)) {
foreach($this->fields as $key=>$value) {
if (is_object($value) && method_exists($value, 'format')) {//is DateTime object
$this->fields[$key] = $value->format("Y-m-d\TH:i:s\Z");
}
}
}
if($this->fields === null) $this->fields = false;
if ($this->connection->debug) error_log("<hr>after _fetch, fields: <pre>".print_r($this->fields,true)." backtrace: ".adodb_backtrace(false));
return $this->fields;
}
/* 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. */
function _close()
{
$rez = sqlsrv_free_stmt($this->_queryID);
$this->_queryID = false;
return $rez;
}
// mssql uses a default date like Dec 30 2000 12:00AM
static function UnixDate($v)
{
return ADORecordSet_array_mssqlnative::UnixDate($v);
}
static function UnixTimeStamp($v)
{
return ADORecordSet_array_mssqlnative::UnixTimeStamp($v);
}
}
class ADORecordSet_array_mssqlnative extends ADORecordSet_array {
function ADORecordSet_array_mssqlnative($id=-1,$mode=false)
{
$this->ADORecordSet_array($id,$mode);
}
// mssql uses a default date like Dec 30 2000 12:00AM
static function UnixDate($v)
{
if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixDate($v);
global $ADODB_mssql_mths,$ADODB_mssql_date_order;
//Dec 30 2000 12:00AM
if ($ADODB_mssql_date_order == 'dmy') {
if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4})|" ,$v, $rr)) {
return parent::UnixDate($v);
}
if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
$theday = $rr[1];
$themth = substr(strtoupper($rr[2]),0,3);
} else {
if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})|" ,$v, $rr)) {
return parent::UnixDate($v);
}
if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
$theday = $rr[2];
$themth = substr(strtoupper($rr[1]),0,3);
}
$themth = $ADODB_mssql_mths[$themth];
if ($themth <= 0) return false;
// h-m-s-MM-DD-YY
return mktime(0,0,0,$themth,$theday,$rr[3]);
}
static function UnixTimeStamp($v)
{
if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixTimeStamp($v);
global $ADODB_mssql_mths,$ADODB_mssql_date_order;
//Dec 30 2000 12:00AM
if ($ADODB_mssql_date_order == 'dmy') {
if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
,$v, $rr)) return parent::UnixTimeStamp($v);
if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
$theday = $rr[1];
$themth = substr(strtoupper($rr[2]),0,3);
} else {
if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
,$v, $rr)) return parent::UnixTimeStamp($v);
if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
$theday = $rr[2];
$themth = substr(strtoupper($rr[1]),0,3);
}
$themth = $ADODB_mssql_mths[$themth];
if ($themth <= 0) return false;
switch (strtoupper($rr[6])) {
case 'P':
if ($rr[4]<12) $rr[4] += 12;
break;
case 'A':
if ($rr[4]==12) $rr[4] = 0;
break;
default:
break;
}
// h-m-s-MM-DD-YY
return mktime($rr[4],$rr[5],0,$themth,$theday,$rr[3]);
}
}
/*
Code Example 1:
select object_name(constid) as constraint_name,
object_name(fkeyid) as table_name,
col_name(fkeyid, fkey) as column_name,
object_name(rkeyid) as referenced_table_name,
col_name(rkeyid, rkey) as referenced_column_name
from sysforeignkeys
where object_name(fkeyid) = x
order by constraint_name, table_name, referenced_table_name, keyno
Code Example 2:
select constraint_name,
column_name,
ordinal_position
from information_schema.key_column_usage
where constraint_catalog = db_name()
and table_name = x
order by constraint_name, ordinal_position
http://www.databasejournal.com/scripts/article.php/1440551
*/
?>

View File

@@ -1,6 +1,6 @@
<?php
/**
* @version V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
* @version V5.06 16 Oct 2008 (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.
@@ -45,7 +45,7 @@ class ADODB_mssqlpo extends ADODB_mssql {
return array($sql,$stmt);
}
function _query($sql,$inputarr)
function _query($sql,$inputarr=false)
{
if (is_string($sql)) $sql = str_replace('||','+',$sql);
return ADODB_mssql::_query($sql,$inputarr);

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -58,7 +58,7 @@ class ADODB_mysql extends ADOConnection {
}
function &MetaTables($ttype=false,$showSchema=false,$mask=false)
function MetaTables($ttype=false,$showSchema=false,$mask=false)
{
$save = $this->metaTablesSQL;
if ($showSchema && is_string($showSchema)) {
@@ -69,14 +69,14 @@ class ADODB_mysql extends ADOConnection {
$mask = $this->qstr($mask);
$this->metaTablesSQL .= " like $mask";
}
$ret =& ADOConnection::MetaTables($ttype,$showSchema);
$ret = ADOConnection::MetaTables($ttype,$showSchema);
$this->metaTablesSQL = $save;
return $ret;
}
function &MetaIndexes ($table, $primary = FALSE, $owner=false)
function MetaIndexes ($table, $primary = FALSE, $owner=false)
{
// save old fetch mode
global $ADODB_FETCH_MODE;
@@ -132,6 +132,7 @@ class ADODB_mysql extends ADOConnection {
// if magic quotes disabled, use mysql_real_escape_string()
function qstr($s,$magic_quotes=false)
{
if (is_null($s)) return 'NULL';
if (!$magic_quotes) {
if (ADODB_PHPVER >= 0x4300) {
@@ -158,7 +159,7 @@ class ADODB_mysql extends ADOConnection {
function GetOne($sql,$inputarr=false)
{
if ($this->compat323 == false && strncasecmp($sql,'sele',4) == 0) {
$rs =& $this->SelectLimit($sql,1,-1,$inputarr);
$rs = $this->SelectLimit($sql,1,-1,$inputarr);
if ($rs) {
$rs->Close();
if ($rs->EOF) return false;
@@ -180,7 +181,7 @@ class ADODB_mysql extends ADOConnection {
return mysql_affected_rows($this->_connectionID);
}
// See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html
// See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html
// Reference on Last_Insert_ID on the recommended way to simulate sequences
var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);";
var $_genSeqSQL = "create table %s (id int not null)";
@@ -228,7 +229,7 @@ class ADODB_mysql extends ADOConnection {
return $this->genID;
}
function &MetaDatabases()
function MetaDatabases()
{
$qid = mysql_list_dbs($this->_connectionID);
$arr = array();
@@ -393,7 +394,7 @@ class ADODB_mysql extends ADOConnection {
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
}
function &MetaColumns($table)
function MetaColumns($table)
{
$this->_findschema($table,$schema);
if ($schema) {
@@ -446,10 +447,10 @@ class ADODB_mysql extends ADOConnection {
$fld->not_null = ($rs->fields[2] != 'YES');
$fld->primary_key = ($rs->fields[3] == 'PRI');
$fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
$fld->binary = (strpos($type,'blob') !== false);
$fld->unsigned = (strpos($type,'unsigned') !== false);
$fld->binary = (strpos($type,'blob') !== false || strpos($type,'binary') !== false);
$fld->unsigned = (strpos($type,'unsigned') !== false);
$fld->zerofill = (strpos($type,'zerofill') !== false);
if (!$fld->binary) {
$d = $rs->fields[4];
if ($d != '' && $d != 'NULL') {
@@ -484,21 +485,21 @@ class ADODB_mysql extends ADOConnection {
}
// parameters use PostgreSQL convention, not MySQL
function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0)
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0)
{
$offsetStr =($offset>=0) ? ((integer)$offset)."," : '';
// jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220
if ($nrows < 0) $nrows = '18446744073709551615';
if ($secs)
$rs =& $this->CacheExecute($secs,$sql." LIMIT $offsetStr".((integer)$nrows),$inputarr);
$rs = $this->CacheExecute($secs,$sql." LIMIT $offsetStr".((integer)$nrows),$inputarr);
else
$rs =& $this->Execute($sql." LIMIT $offsetStr".((integer)$nrows),$inputarr);
$rs = $this->Execute($sql." LIMIT $offsetStr".((integer)$nrows),$inputarr);
return $rs;
}
// returns queryID or false
function _query($sql,$inputarr)
function _query($sql,$inputarr=false)
{
//global $ADODB_COUNTRECS;
//if($ADODB_COUNTRECS)
@@ -558,8 +559,9 @@ class ADODB_mysql extends ADOConnection {
$table = "$owner.$table";
}
$a_create_table = $this->getRow(sprintf('SHOW CREATE TABLE %s', $table));
if ($associative) $create_sql = $a_create_table["Create Table"];
else $create_sql = $a_create_table[1];
if ($associative) {
$create_sql = isset($a_create_table["Create Table"]) ? $a_create_table["Create Table"] : $a_create_table["Create View"];
} else $create_sql = $a_create_table[1];
$matches = array();
@@ -575,9 +577,12 @@ class ADODB_mysql extends ADOConnection {
$ref_table = strtoupper($ref_table);
}
$foreign_keys[$ref_table] = array();
$num_fields = count($my_field);
for ( $j = 0; $j < $num_fields; $j ++ ) {
// see https://sourceforge.net/tracker/index.php?func=detail&aid=2287278&group_id=42718&atid=433976
if (!isset($foreign_keys[$ref_table])) {
$foreign_keys[$ref_table] = array();
}
$num_fields = count($my_field);
for ( $j = 0; $j < $num_fields; $j ++ ) {
if ( $associative ) {
$foreign_keys[$ref_table][$ref_field[$j]] = $my_field[$j];
} else {
@@ -629,28 +634,28 @@ class ADORecordSet_mysql extends ADORecordSet{
$this->_numOfFields = @mysql_num_fields($this->_queryID);
}
function &FetchField($fieldOffset = -1)
function FetchField($fieldOffset = -1)
{
if ($fieldOffset != -1) {
$o = @mysql_fetch_field($this->_queryID, $fieldOffset);
$f = @mysql_field_flags($this->_queryID,$fieldOffset);
$o->max_length = @mysql_field_len($this->_queryID,$fieldOffset); // suggested by: Jim Nicholson (jnich#att.com)
if ($o) $o->max_length = @mysql_field_len($this->_queryID,$fieldOffset); // suggested by: Jim Nicholson (jnich#att.com)
//$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable
$o->binary = (strpos($f,'binary')!== false);
if ($o) $o->binary = (strpos($f,'binary')!== false);
}
else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */
$o = @mysql_fetch_field($this->_queryID);
$o->max_length = @mysql_field_len($this->_queryID); // suggested by: Jim Nicholson (jnich#att.com)
if ($o) $o->max_length = @mysql_field_len($this->_queryID); // suggested by: Jim Nicholson (jnich#att.com)
//$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable
}
return $o;
}
function &GetRowAssoc($upper=true)
function GetRowAssoc($upper=true)
{
if ($this->fetchMode == MYSQL_ASSOC && !$upper) $row = $this->fields;
else $row =& ADORecordSet::GetRowAssoc($upper);
else $row = ADORecordSet::GetRowAssoc($upper);
return $row;
}
@@ -732,6 +737,7 @@ class ADORecordSet_mysql extends ADORecordSet{
case 'LONGBLOB':
case 'BLOB':
case 'MEDIUMBLOB':
case 'BINARY':
return !empty($fieldobj->binary) ? 'B' : 'X';
case 'YEAR':

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -50,6 +50,7 @@ class ADODB_mysqli extends ADOConnection {
var $_bindInputArray = false;
var $nameQuote = '`'; /// string to use to quote identifiers and names
var $optionFlags = array(array(MYSQLI_READ_DEFAULT_GROUP,0));
var $arrayClass = 'ADORecordSet_array_mysqli';
function ADODB_mysqli()
{
@@ -113,6 +114,7 @@ class ADODB_mysqli extends ADOConnection {
} else {
if ($this->debug)
ADOConnection::outp("Could't connect : " . $this->ErrorMsg());
$this->_connectionID = null;
return false;
}
}
@@ -142,7 +144,7 @@ class ADODB_mysqli extends ADOConnection {
function GetOne($sql,$inputarr=false)
{
$ret = false;
$rs = &$this->Execute($sql,$inputarr);
$rs = $this->Execute($sql,$inputarr);
if ($rs) {
if (!$rs->EOF) $ret = reset($rs->fields);
$rs->Close();
@@ -196,7 +198,7 @@ class ADODB_mysqli extends ADOConnection {
{
if ($this->transCnt==0) $this->BeginTrans();
if ($where) $where = ' where '.$where;
$rs =& $this->Execute("select $flds from $tables $where for update");
$rs = $this->Execute("select $flds from $tables $where for update");
return !empty($rs);
}
@@ -212,6 +214,7 @@ class ADODB_mysqli extends ADOConnection {
//Eg. $s = $db->qstr(_GET['name'],get_magic_quotes_gpc());
function qstr($s, $magic_quotes = false)
{
if (is_null($s)) return 'NULL';
if (!$magic_quotes) {
if (PHP_VERSION >= 5)
return "'" . mysqli_real_escape_string($this->_connectionID, $s) . "'";
@@ -248,6 +251,7 @@ class ADODB_mysqli extends ADOConnection {
// Reference on Last_Insert_ID on the recommended way to simulate sequences
var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);";
var $_genSeqSQL = "create table %s (id int not null)";
var $_genSeqCountSQL = "select count(*) from %s";
var $_genSeq2SQL = "insert into %s values (%s)";
var $_dropSeqSQL = "drop table %s";
@@ -287,10 +291,10 @@ class ADODB_mysqli extends ADOConnection {
return $this->genID;
}
function &MetaDatabases()
function MetaDatabases()
{
$query = "SHOW DATABASES";
$ret =& $this->Execute($query);
$ret = $this->Execute($query);
if ($ret && is_object($ret)){
$arr = array();
while (!$ret->EOF){
@@ -304,7 +308,7 @@ class ADODB_mysqli extends ADOConnection {
}
function &MetaIndexes ($table, $primary = FALSE)
function MetaIndexes ($table, $primary = FALSE)
{
// save old fetch mode
global $ADODB_FETCH_MODE;
@@ -459,7 +463,7 @@ class ADODB_mysqli extends ADOConnection {
// return "from_unixtime(unix_timestamp($date)+$fraction)";
}
function &MetaTables($ttype=false,$showSchema=false,$mask=false)
function MetaTables($ttype=false,$showSchema=false,$mask=false)
{
$save = $this->metaTablesSQL;
if ($showSchema && is_string($showSchema)) {
@@ -470,7 +474,7 @@ class ADODB_mysqli extends ADOConnection {
$mask = $this->qstr($mask);
$this->metaTablesSQL .= " like $mask";
}
$ret =& ADOConnection::MetaTables($ttype,$showSchema);
$ret = ADOConnection::MetaTables($ttype,$showSchema);
$this->metaTablesSQL = $save;
return $ret;
@@ -487,8 +491,9 @@ class ADODB_mysqli extends ADOConnection {
$table = "$owner.$table";
}
$a_create_table = $this->getRow(sprintf('SHOW CREATE TABLE %s', $table));
if ($associative) $create_sql = $a_create_table["Create Table"];
else $create_sql = $a_create_table[1];
if ($associative) {
$create_sql = isset($a_create_table["Create Table"]) ? $a_create_table["Create Table"] : $a_create_table["Create View"];
} else $create_sql = $a_create_table[1];
$matches = array();
@@ -504,8 +509,11 @@ class ADODB_mysqli extends ADOConnection {
$ref_table = strtoupper($ref_table);
}
$foreign_keys[$ref_table] = array();
$num_fields = count($my_field);
// see https://sourceforge.net/tracker/index.php?func=detail&aid=2287278&group_id=42718&atid=433976
if (!isset($foreign_keys[$ref_table])) {
$foreign_keys[$ref_table] = array();
}
$num_fields = count($my_field);
for ( $j = 0; $j < $num_fields; $j ++ ) {
if ( $associative ) {
$foreign_keys[$ref_table][$ref_field[$j]] = $my_field[$j];
@@ -518,7 +526,7 @@ class ADODB_mysqli extends ADOConnection {
return $foreign_keys;
}
function &MetaColumns($table)
function MetaColumns($table)
{
$false = false;
if (!$this->metaColumnsSQL)
@@ -552,8 +560,10 @@ class ADODB_mysqli extends ADOConnection {
$fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
} elseif (preg_match("/^(enum)\((.*)\)$/i", $type, $query_array)) {
$fld->type = $query_array[1];
$fld->max_length = max(array_map("strlen",explode(",",$query_array[2]))) - 2; // PHP >= 4.0.6
$fld->max_length = ($fld->max_length == 0 ? 1 : $fld->max_length);
$arr = explode(",",$query_array[2]);
$fld->enums = $arr;
$zlen = max(array_map("strlen",$arr)) - 2; // PHP >= 4.0.6
$fld->max_length = ($zlen > 0) ? $zlen : 1;
} else {
$fld->type = $type;
$fld->max_length = -1;
@@ -605,20 +615,19 @@ class ADODB_mysqli extends ADOConnection {
}
// parameters use PostgreSQL convention, not MySQL
function &SelectLimit($sql,
function SelectLimit($sql,
$nrows = -1,
$offset = -1,
$inputarr = false,
$arg3 = false,
$secs = 0)
{
$offsetStr = ($offset >= 0) ? "$offset," : '';
if ($nrows < 0) $nrows = '18446744073709551615';
if ($secs)
$rs =& $this->CacheExecute($secs, $sql . " LIMIT $offsetStr$nrows" , $inputarr , $arg3);
$rs = $this->CacheExecute($secs, $sql . " LIMIT $offsetStr$nrows" , $inputarr );
else
$rs =& $this->Execute($sql . " LIMIT $offsetStr$nrows" , $inputarr , $arg3);
$rs = $this->Execute($sql . " LIMIT $offsetStr$nrows" , $inputarr );
return $rs;
}
@@ -627,7 +636,6 @@ class ADODB_mysqli extends ADOConnection {
function Prepare($sql)
{
return $sql;
$stmt = $this->_connectionID->prepare($sql);
if (!$stmt) {
echo $this->ErrorMsg();
@@ -641,8 +649,18 @@ class ADODB_mysqli extends ADOConnection {
function _query($sql, $inputarr)
{
global $ADODB_COUNTRECS;
// Move to the next recordset, or return false if there is none. In a stored proc
// call, mysqli_next_result returns true for the last "recordset", but mysqli_store_result
// returns false. I think this is because the last "recordset" is actually just the
// return value of the stored proc (ie the number of rows affected).
// Commented out for reasons of performance. You should retrieve every recordset yourself.
// if (!mysqli_next_result($this->connection->_connectionID)) return false;
if (is_array($sql)) {
// Prepare() not supported because mysqli_stmt_execute does not return a recordset, but
// returns as bound variables.
$stmt = $sql[1];
$a = '';
foreach($inputarr as $k => $v) {
@@ -653,16 +671,28 @@ class ADODB_mysqli extends ADOConnection {
$fnarr = array_merge( array($stmt,$a) , $inputarr);
$ret = call_user_func_array('mysqli_stmt_bind_param',$fnarr);
$ret = mysqli_stmt_execute($stmt);
return $ret;
}
/*
if (!$mysql_res = mysqli_query($this->_connectionID, $sql, ($ADODB_COUNTRECS) ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT)) {
if ($this->debug) ADOConnection::outp("Query: " . $sql . " failed. " . $this->ErrorMsg());
return false;
}
return $mysql_res;
*/
if( $rs = mysqli_multi_query($this->_connectionID, $sql.';') )//Contributed by "Geisel Sierote" <geisel#4up.com.br>
{
$rs = ($ADODB_COUNTRECS) ? @mysqli_store_result( $this->_connectionID ) : @mysqli_use_result( $this->_connectionID );
return $rs ? $rs : true; // mysqli_more_results( $this->_connectionID )
} else {
if($this->debug)
ADOConnection::outp("Query: " . $sql . " failed. " . $this->ErrorMsg());
return false;
}
}
/* Returns: the last error message from previous database operation */
@@ -812,13 +842,14 @@ class ADORecordSet_mysqli extends ADORecordSet{
131072 = MYSQLI_BINCMP_FLAG
*/
function &FetchField($fieldOffset = -1)
function FetchField($fieldOffset = -1)
{
$fieldnr = $fieldOffset;
if ($fieldOffset != -1) {
$fieldOffset = mysqli_field_seek($this->_queryID, $fieldnr);
$fieldOffset = @mysqli_field_seek($this->_queryID, $fieldnr);
}
$o = mysqli_fetch_field($this->_queryID);
$o = @mysqli_fetch_field($this->_queryID);
if (!$o) return false;
/* Properties of an ADOFieldObject as set by MetaColumns */
$o->primary_key = $o->flags & MYSQLI_PRI_KEY_FLAG;
$o->not_null = $o->flags & MYSQLI_NOT_NULL_FLAG;
@@ -830,11 +861,11 @@ class ADORecordSet_mysqli extends ADORecordSet{
return $o;
}
function &GetRowAssoc($upper = true)
function GetRowAssoc($upper = true)
{
if ($this->fetchMode == MYSQLI_ASSOC && !$upper)
return $this->fields;
$row =& ADORecordSet::GetRowAssoc($upper);
$row = ADORecordSet::GetRowAssoc($upper);
return $row;
}
@@ -867,6 +898,33 @@ class ADORecordSet_mysqli extends ADORecordSet{
return true;
}
function NextRecordSet()
{
global $ADODB_COUNTRECS;
mysqli_free_result($this->_queryID);
$this->_queryID = -1;
// Move to the next recordset, or return false if there is none. In a stored proc
// call, mysqli_next_result returns true for the last "recordset", but mysqli_store_result
// returns false. I think this is because the last "recordset" is actually just the
// return value of the stored proc (ie the number of rows affected).
if(!mysqli_next_result($this->connection->_connectionID)) {
return false;
}
// CD: There is no $this->_connectionID variable, at least in the ADO version I'm using
$this->_queryID = ($ADODB_COUNTRECS) ? @mysqli_store_result( $this->connection->_connectionID )
: @mysqli_use_result( $this->connection->_connectionID );
if(!$this->_queryID) {
return false;
}
$this->_inited = false;
$this->bind = false;
$this->_currentRow = -1;
$this->Init();
return true;
}
// 10% speedup to move MoveNext to child class
// This is the only implementation that works now (23-10-2003).
// Other functions return no or the wrong results.
@@ -942,7 +1000,7 @@ class ADORecordSet_mysqli extends ADORecordSet{
case 'SET':
case MYSQLI_TYPE_TINY_BLOB :
case MYSQLI_TYPE_CHAR :
#case MYSQLI_TYPE_CHAR :
case MYSQLI_TYPE_STRING :
case MYSQLI_TYPE_ENUM :
case MYSQLI_TYPE_SET :
@@ -1022,4 +1080,108 @@ class ADORecordSet_mysqli extends ADORecordSet{
}
class ADORecordSet_array_mysqli extends ADORecordSet_array {
function ADORecordSet_array_mysqli($id=-1,$mode=false)
{
$this->ADORecordSet_array($id,$mode);
}
function MetaType($t, $len = -1, $fieldobj = false)
{
if (is_object($t)) {
$fieldobj = $t;
$t = $fieldobj->type;
$len = $fieldobj->max_length;
}
$len = -1; // mysql max_length is not accurate
switch (strtoupper($t)) {
case 'STRING':
case 'CHAR':
case 'VARCHAR':
case 'TINYBLOB':
case 'TINYTEXT':
case 'ENUM':
case 'SET':
case MYSQLI_TYPE_TINY_BLOB :
#case MYSQLI_TYPE_CHAR :
case MYSQLI_TYPE_STRING :
case MYSQLI_TYPE_ENUM :
case MYSQLI_TYPE_SET :
case 253 :
if ($len <= $this->blobSize) return 'C';
case 'TEXT':
case 'LONGTEXT':
case 'MEDIUMTEXT':
return 'X';
// php_mysql extension always returns 'blob' even if 'text'
// so we have to check whether binary...
case 'IMAGE':
case 'LONGBLOB':
case 'BLOB':
case 'MEDIUMBLOB':
case MYSQLI_TYPE_BLOB :
case MYSQLI_TYPE_LONG_BLOB :
case MYSQLI_TYPE_MEDIUM_BLOB :
return !empty($fieldobj->binary) ? 'B' : 'X';
case 'YEAR':
case 'DATE':
case MYSQLI_TYPE_DATE :
case MYSQLI_TYPE_YEAR :
return 'D';
case 'TIME':
case 'DATETIME':
case 'TIMESTAMP':
case MYSQLI_TYPE_DATETIME :
case MYSQLI_TYPE_NEWDATE :
case MYSQLI_TYPE_TIME :
case MYSQLI_TYPE_TIMESTAMP :
return 'T';
case 'INT':
case 'INTEGER':
case 'BIGINT':
case 'TINYINT':
case 'MEDIUMINT':
case 'SMALLINT':
case MYSQLI_TYPE_INT24 :
case MYSQLI_TYPE_LONG :
case MYSQLI_TYPE_LONGLONG :
case MYSQLI_TYPE_SHORT :
case MYSQLI_TYPE_TINY :
if (!empty($fieldobj->primary_key)) return 'R';
return 'I';
// Added floating-point types
// Maybe not necessery.
case 'FLOAT':
case 'DOUBLE':
// case 'DOUBLE PRECISION':
case 'DECIMAL':
case 'DEC':
case 'FIXED':
default:
//if (!is_numeric($t)) echo "<p>--- Error in type matching $t -----</p>";
return 'N';
}
} // function
}
?>

View File

@@ -0,0 +1,138 @@
<?php
/*
V5.08 6 Apr 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.
Set tabs to 8.
MySQL code that supports transactions. For MySQL 3.23 or later.
Code from James Poon <jpoon88@yahoo.com>
Requires mysql client. Works on Windows and Unix.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
include_once(ADODB_DIR."/drivers/adodb-mysql.inc.php");
class ADODB_mysqlt extends ADODB_mysql {
var $databaseType = 'mysqlt';
var $ansiOuter = true; // for Version 3.23.17 or later
var $hasTransactions = true;
var $autoRollback = true; // apparently mysql does not autorollback properly
function ADODB_mysqlt()
{
global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_';
}
function BeginTrans()
{
if ($this->transOff) return true;
$this->transCnt += 1;
$this->Execute('SET AUTOCOMMIT=0');
$this->Execute('BEGIN');
return true;
}
function CommitTrans($ok=true)
{
if ($this->transOff) return true;
if (!$ok) return $this->RollbackTrans();
if ($this->transCnt) $this->transCnt -= 1;
$this->Execute('COMMIT');
$this->Execute('SET AUTOCOMMIT=1');
return true;
}
function RollbackTrans()
{
if ($this->transOff) return true;
if ($this->transCnt) $this->transCnt -= 1;
$this->Execute('ROLLBACK');
$this->Execute('SET AUTOCOMMIT=1');
return true;
}
function RowLock($tables,$where='',$flds='1 as adodb_ignore')
{
if ($this->transCnt==0) $this->BeginTrans();
if ($where) $where = ' where '.$where;
$rs = $this->Execute("select $flds from $tables $where for update");
return !empty($rs);
}
}
class ADORecordSet_mysqlt extends ADORecordSet_mysql{
var $databaseType = "mysqlt";
function ADORecordSet_mysqlt($queryID,$mode=false)
{
if ($mode === false) {
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
}
switch ($mode)
{
case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
case ADODB_FETCH_DEFAULT:
case ADODB_FETCH_BOTH:
default: $this->fetchMode = MYSQL_BOTH; break;
}
$this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID);
}
function MoveNext()
{
if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
$this->_currentRow += 1;
return true;
}
if (!$this->EOF) {
$this->_currentRow += 1;
$this->EOF = true;
}
return false;
}
}
class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
function ADORecordSet_ext_mysqlt($queryID,$mode=false)
{
if ($mode === false) {
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
}
switch ($mode)
{
case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
case ADODB_FETCH_DEFAULT:
case ADODB_FETCH_BOTH:
default:
$this->fetchMode = MYSQL_BOTH; break;
}
$this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID);
}
function MoveNext()
{
return adodb_movenext($this);
}
}
?>

View File

@@ -1,7 +1,7 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -62,25 +62,25 @@ class ADODB_mysqlt extends ADODB_mysql {
if (!$ok) return $this->RollbackTrans();
if ($this->transCnt) $this->transCnt -= 1;
$this->Execute('COMMIT');
$ok = $this->Execute('COMMIT');
$this->Execute('SET AUTOCOMMIT=1');
return true;
return $ok ? true : false;
}
function RollbackTrans()
{
if ($this->transOff) return true;
if ($this->transCnt) $this->transCnt -= 1;
$this->Execute('ROLLBACK');
$ok = $this->Execute('ROLLBACK');
$this->Execute('SET AUTOCOMMIT=1');
return true;
return $ok ? true : false;
}
function RowLock($tables,$where='',$flds='1 as adodb_ignore')
{
if ($this->transCnt==0) $this->BeginTrans();
if ($where) $where = ' where '.$where;
$rs =& $this->Execute("select $flds from $tables $where for update");
$rs = $this->Execute("select $flds from $tables $where for update");
return !empty($rs);
}

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
First cut at the Netezza Driver by Josh Eldridge joshuae74#hotmail.com
Based on the previous postgres drivers.
@@ -53,7 +53,7 @@ class ADODB_netezza extends ADODB_postgres64 {
}
function &MetaColumns($table,$upper=true)
function MetaColumns($table,$upper=true)
{
// Changed this function to support Netezza which has no concept of keys
@@ -67,7 +67,7 @@ class ADODB_netezza extends ADODB_postgres64 {
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
$rs =& $this->Execute(sprintf($this->metaColumnsSQL,$table,$table));
$rs = $this->Execute(sprintf($this->metaColumnsSQL,$table,$table));
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;

View File

@@ -1,7 +1,7 @@
<?php
/*
version V4.94 23 Jan 2007 (c) 2000-2007 John Lim. All rights reserved.
version V5.06 16 Oct 2008 (c) 2000-2009 John Lim. All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
@@ -81,13 +81,13 @@ class ADODB_oci8 extends ADOConnection {
var $leftOuter = ''; // oracle wierdness, $col = $value (+) for LEFT OUTER, $col (+)= $value for RIGHT OUTER
var $session_sharing_force_blob = false; // alter session on updateblob if set to true
var $firstrows = true; // enable first rows optimization on SelectLimit()
var $selectOffsetAlg1 = 100; // when to use 1st algorithm of selectlimit.
var $selectOffsetAlg1 = 1000; // when to use 1st algorithm of selectlimit.
var $NLS_DATE_FORMAT = 'YYYY-MM-DD'; // To include time, use 'RRRR-MM-DD HH24:MI:SS'
var $dateformat = 'YYYY-MM-DD'; // for DBDate()
var $dateformat = 'YYYY-MM-DD'; // DBDate format
var $useDBDateFormatForTextInput=false;
var $datetime = false; // MetaType('DATE') returns 'D' (datetime==false) or 'T' (datetime == true)
var $_refLOBs = array();
// var $ansiOuter = true; // if oracle9
function ADODB_oci8()
@@ -96,8 +96,8 @@ class ADODB_oci8 extends ADOConnection {
if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_';
}
/* Function &MetaColumns($table) added by smondino@users.sourceforge.net*/
function &MetaColumns($table)
/* function MetaColumns($table) added by smondino@users.sourceforge.net*/
function MetaColumns($table)
{
global $ADODB_FETCH_MODE;
@@ -141,7 +141,7 @@ class ADODB_oci8 extends ADOConnection {
function Time()
{
$rs =& $this->Execute("select TO_CHAR($this->sysTimeStamp,'YYYY-MM-DD HH24:MI:SS') from dual");
$rs = $this->Execute("select TO_CHAR($this->sysTimeStamp,'YYYY-MM-DD HH24:MI:SS') from dual");
if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields));
return false;
@@ -184,7 +184,7 @@ NATSOFT.DOMAIN =
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$mode=0)
{
if (!function_exists('OCIPLogon')) return null;
#adodb_backtrace();
$this->_errorMsg = false;
$this->_errorCode = false;
@@ -200,6 +200,11 @@ NATSOFT.DOMAIN =
$argHostport = empty($this->port)? "1521" : $this->port;
}
if (strncasecmp($argDatabasename,'SID=',4) == 0) {
$argDatabasename = substr($argDatabasename,4);
$this->connectSID = true;
}
if ($this->connectSID) {
$argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname
.")(PORT=$argHostport))(CONNECT_DATA=(SID=$argDatabasename)))";
@@ -272,10 +277,10 @@ NATSOFT.DOMAIN =
}
// format and return date string in database date format
function DBDate($d)
function DBDate($d,$isfld=false)
{
if (empty($d) && $d !== 0) return 'null';
if ($isfld) return 'TO_DATE('.$d.",'".$this->dateformat."')";
if (is_string($d)) $d = ADORecordSet::UnixDate($d);
return "TO_DATE(".adodb_date($this->fmtDate,$d).",'".$this->dateformat."')";
}
@@ -297,9 +302,10 @@ NATSOFT.DOMAIN =
}
// format and return date string in database timestamp format
function DBTimeStamp($ts)
function DBTimeStamp($ts,$isfld=false)
{
if (empty($ts) && $ts !== 0) return 'null';
if ($isfld) return 'TO_DATE(substr('.$ts.",1,19),'RRRR-MM-DD, HH24:MI:SS')";
if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts);
return 'TO_DATE('.adodb_date("'Y-m-d H:i:s'",$ts).",'RRRR-MM-DD, HH24:MI:SS')";
}
@@ -310,14 +316,14 @@ NATSOFT.DOMAIN =
return $this->GetOne("select $flds from $tables where $where for update");
}
function &MetaTables($ttype=false,$showSchema=false,$mask=false)
function MetaTables($ttype=false,$showSchema=false,$mask=false)
{
if ($mask) {
$save = $this->metaTablesSQL;
$mask = $this->qstr(strtoupper($mask));
$this->metaTablesSQL .= " AND upper(table_name) like $mask";
}
$ret =& ADOConnection::MetaTables($ttype,$showSchema);
$ret = ADOConnection::MetaTables($ttype,$showSchema);
if ($mask) {
$this->metaTablesSQL = $save;
@@ -326,7 +332,7 @@ NATSOFT.DOMAIN =
}
// Mark Newnham
function &MetaIndexes ($table, $primary = FALSE, $owner=false)
function MetaIndexes ($table, $primary = FALSE, $owner=false)
{
// save old fetch mode
global $ADODB_FETCH_MODE;
@@ -399,8 +405,10 @@ NATSOFT.DOMAIN =
$this->autoCommit = false;
$this->_commit = OCI_DEFAULT;
if ($this->_transmode) $this->Execute("SET TRANSACTION ".$this->_transmode);
return true;
if ($this->_transmode) $ok = $this->Execute("SET TRANSACTION ".$this->_transmode);
else $ok = true;
return $ok ? true : false;
}
function CommitTrans($ok=true)
@@ -541,6 +549,12 @@ NATSOFT.DOMAIN =
return $s. "')";
}
function GetRandRow($sql, $arr = false)
{
$sql = "SELECT * FROM ($sql ORDER BY dbms_random.value) WHERE rownum = 1";
return $this->GetRow($sql,$arr);
}
/*
This algorithm makes use of
@@ -557,7 +571,7 @@ NATSOFT.DOMAIN =
This implementation does not appear to work with oracle 8.0.5 or earlier. Comment
out this function then, and the slower SelectLimit() in the base class will be used.
*/
function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
{
// seems that oracle only supports 1 hint comment in 8i
if ($this->firstrows) {
@@ -567,7 +581,7 @@ NATSOFT.DOMAIN =
$sql = preg_replace('/^[ \t\n]*select/i','SELECT /*+FIRST_ROWS*/',$sql);
}
if ($offset < $this->selectOffsetAlg1) {
if ($offset == -1 || ($offset < $this->selectOffsetAlg1 && 0 < $nrows && $nrows < 1000)) {
if ($nrows > 0) {
if ($offset > 0) $nrows += $offset;
//$inputarr['adodb_rownum'] = $nrows;
@@ -581,7 +595,7 @@ NATSOFT.DOMAIN =
}
// note that $nrows = 0 still has to work ==> no rows returned
$rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
$rs = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
return $rs;
} else {
@@ -589,14 +603,14 @@ NATSOFT.DOMAIN =
// Let Oracle return the name of the columns
$q_fields = "SELECT * FROM (".$sql.") WHERE NULL = NULL";
$false = false;
if (! $stmt_arr = $this->Prepare($q_fields)) {
return $false;
}
$stmt = $stmt_arr[1];
if (is_array($inputarr)) {
if (is_array($inputarr)) {
foreach($inputarr as $k => $v) {
if (is_array($v)) {
if (sizeof($v) == 2) // suggested by g.giunta@libero.
@@ -610,6 +624,7 @@ NATSOFT.DOMAIN =
$bindarr[$k] = $v;
} else { // dynamic sql, so rebind every time
OCIBindByName($stmt,":$k",$inputarr[$k],$len);
}
}
}
@@ -628,16 +643,17 @@ NATSOFT.DOMAIN =
OCIFreeStatement($stmt);
$fields = implode(',', $cols);
$nrows += $offset;
if ($nrows <= 0) $nrows = 999999999999;
else $nrows += $offset;
$offset += 1; // in Oracle rownum starts at 1
if ($this->databaseType == 'oci8po') {
$sql = "SELECT $fields FROM".
$sql = "SELECT /*+ FIRST_ROWS */ $fields FROM".
"(SELECT rownum as adodb_rownum, $fields FROM".
" ($sql) WHERE rownum <= ?".
") WHERE adodb_rownum >= ?";
} else {
$sql = "SELECT $fields FROM".
$sql = "SELECT /*+ FIRST_ROWS */ $fields FROM".
"(SELECT rownum as adodb_rownum, $fields FROM".
" ($sql) WHERE rownum <= :adodb_nrows".
") WHERE adodb_rownum >= :adodb_offset";
@@ -645,8 +661,8 @@ NATSOFT.DOMAIN =
$inputarr['adodb_nrows'] = $nrows;
$inputarr['adodb_offset'] = $offset;
if ($secs2cache>0) $rs =& $this->CacheExecute($secs2cache, $sql,$inputarr);
else $rs =& $this->Execute($sql,$inputarr);
if ($secs2cache>0) $rs = $this->CacheExecute($secs2cache, $sql,$inputarr);
else $rs = $this->Execute($sql,$inputarr);
return $rs;
}
@@ -704,7 +720,7 @@ NATSOFT.DOMAIN =
}
/**
* Usage: store file pointed to by $var in a blob
* Usage: store file pointed to by $val in a blob
*/
function UpdateBlobFile($table,$column,$val,$where,$blobtype='BLOB')
{
@@ -739,11 +755,11 @@ NATSOFT.DOMAIN =
* @param [inputarr] holds the input data to bind to. Null elements will be set to null.
* @return RecordSet or false
*/
function &Execute($sql,$inputarr=false)
function Execute($sql,$inputarr=false)
{
if ($this->fnExecute) {
$fn = $this->fnExecute;
$ret =& $fn($this,$sql,$inputarr);
$ret = $fn($this,$sql,$inputarr);
if (isset($ret)) return $ret;
}
if ($inputarr) {
@@ -751,6 +767,7 @@ NATSOFT.DOMAIN =
$element0 = reset($inputarr);
if (!$this->_bindInputArray) {
# is_object check because oci8 descriptors can be passed in
if (is_array($element0) && !is_object(reset($element0))) {
if (is_string($sql))
@@ -759,15 +776,48 @@ NATSOFT.DOMAIN =
$stmt = $sql;
foreach($inputarr as $arr) {
$ret =& $this->_Execute($stmt,$arr);
$ret = $this->_Execute($stmt,$arr);
if (!$ret) return $ret;
}
} else {
$ret =& $this->_Execute($sql,$inputarr);
$sqlarr = explode(':',$sql);
$sql = '';
$lastnomatch = -2;
#var_dump($sqlarr);echo "<hr>";var_dump($inputarr);echo"<hr>";
foreach($sqlarr as $k => $str) {
if ($k == 0) { $sql = $str; continue; }
// we need $lastnomatch because of the following datetime,
// eg. '10:10:01', which causes code to think that there is bind param :10 and :1
$ok = preg_match('/^([0-9]*)/', $str, $arr);
if (!$ok) $sql .= $str;
else {
$at = $arr[1];
if (isset($inputarr[$at]) || is_null($inputarr[$at])) {
if ((strlen($at) == strlen($str) && $k < sizeof($arr)-1)) {
$sql .= ':'.$str;
$lastnomatch = $k;
} else if ($lastnomatch == $k-1) {
$sql .= ':'.$str;
} else {
if (is_null($inputarr[$at])) $sql .= 'null';
else $sql .= $this->qstr($inputarr[$at]);
$sql .= substr($str, strlen($at));
}
} else {
$sql .= ':'.$str;
}
}
}
$inputarr = false;
}
}
$ret = $this->_Execute($sql,$inputarr);
} else {
$ret =& $this->_Execute($sql,false);
$ret = $this->_Execute($sql,false);
}
return $ret;
@@ -818,7 +868,7 @@ NATSOFT.DOMAIN =
array('VAR1' => 'Mr Bean'));
*/
function &ExecuteCursor($sql,$cursorName='rs',$params=false)
function ExecuteCursor($sql,$cursorName='rs',$params=false)
{
if (is_array($sql)) $stmt = $sql;
else $stmt = ADODB_oci8::Prepare($sql,true); # true to allocate OCINewCursor
@@ -835,7 +885,7 @@ NATSOFT.DOMAIN =
} else
$hasref = false;
$rs =& $this->Execute($stmt);
$rs = $this->Execute($stmt);
if ($rs) {
if ($rs->databaseType == 'array') OCIFreeCursor($stmt[4]);
else if ($hasref) $rs->_refcursor = $stmt[4];
@@ -895,7 +945,7 @@ NATSOFT.DOMAIN =
$this->_refLOBs[$numlob]['LOB'] = OCINewDescriptor($this->_connectionID, oci_lob_desc($type));
$this->_refLOBs[$numlob]['TYPE'] = $isOutput;
$tmp = &$this->_refLOBs[$numlob]['LOB'];
$tmp = $this->_refLOBs[$numlob]['LOB'];
$rez = OCIBindByName($stmt[1], ":".$name, $tmp, -1, $type);
if ($this->debug) {
ADOConnection::outp("<b>Bind</b>: descriptor has been allocated, var (".$name.") binded");
@@ -910,7 +960,7 @@ NATSOFT.DOMAIN =
ADOConnection::outp("<b>Bind</b>: LOB has been written to temp");
}
} else {
$this->_refLOBs[$numlob]['VAR'] = &$var;
$this->_refLOBs[$numlob]['VAR'] = $var;
}
$rez = $tmp;
} else {
@@ -970,7 +1020,7 @@ NATSOFT.DOMAIN =
$db->bind($stmt,1); $db->bind($stmt,2); $db->bind($stmt,3);
$db->execute($stmt);
*/
function _query($sql,$inputarr)
function _query($sql,$inputarr=false)
{
if (is_array($sql)) { // is prepared sql
$stmt = $sql[1];
@@ -981,7 +1031,7 @@ NATSOFT.DOMAIN =
$bindpos = $sql[3];
if (isset($this->_bind[$bindpos])) {
// all tied up already
$bindarr = &$this->_bind[$bindpos];
$bindarr = $this->_bind[$bindpos];
} else {
// one statement to bind them all
$bindarr = array();
@@ -989,7 +1039,7 @@ NATSOFT.DOMAIN =
$bindarr[$k] = $v;
OCIBindByName($stmt,":$k",$bindarr[$k],is_string($v) && strlen($v)>4000 ? -1 : 4000);
}
$this->_bind[$bindpos] = &$bindarr;
$this->_bind[$bindpos] = $bindarr;
}
}
} else {
@@ -1009,7 +1059,13 @@ NATSOFT.DOMAIN =
else
OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1],$v[2]);
if ($this->debug==99) echo "name=:$k",' var='.$inputarr[$k][0],' len='.$v[1],' type='.$v[2],'<br>';
if ($this->debug==99) {
if (is_object($v[0]))
echo "name=:$k",' len='.$v[1],' type='.$v[2],'<br>';
else
echo "name=:$k",' var='.$inputarr[$k][0],' len='.$v[1],' type='.$v[2],'<br>';
}
} else {
$len = -1;
if ($v === ' ') $len = 1;
@@ -1076,6 +1132,32 @@ NATSOFT.DOMAIN =
return false;
}
// From Oracle Whitepaper: PHP Scalability and High Availability
function IsConnectionError($err)
{
switch($err) {
case 378: /* buffer pool param incorrect */
case 602: /* core dump */
case 603: /* fatal error */
case 609: /* attach failed */
case 1012: /* not logged in */
case 1033: /* init or shutdown in progress */
case 1043: /* Oracle not available */
case 1089: /* immediate shutdown in progress */
case 1090: /* shutdown in progress */
case 1092: /* instance terminated */
case 3113: /* disconnect */
case 3114: /* not connected */
case 3122: /* closing window */
case 3135: /* lost contact */
case 12153: /* TNS: not connected */
case 27146: /* fatal or instance terminated */
case 28511: /* Lost RPC */
return true;
}
return false;
}
// returns true or false
function _close()
{
@@ -1118,7 +1200,7 @@ SELECT /*+ RULE */ distinct b.column_name
$rs = $this->Execute($sql);
if ($rs && !$rs->EOF) {
$arr =& $rs->GetArray();
$arr = $rs->GetArray();
$a = array();
foreach($arr as $v) {
$a[] = reset($v);
@@ -1149,7 +1231,7 @@ SELECT /*+ RULE */ distinct b.column_name
from {$tabp}constraints
where constraint_type = 'R' and table_name = $table $owner";
$constraints =& $this->GetArray($sql);
$constraints = $this->GetArray($sql);
$arr = false;
foreach($constraints as $constr) {
$cons = $this->qstr($constr[0]);
@@ -1290,24 +1372,31 @@ class ADORecordset_oci8 extends ADORecordSet {
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. */
function &_FetchField($fieldOffset = -1)
function _FetchField($fieldOffset = -1)
{
$fld = new ADOFieldObject;
$fieldOffset += 1;
$fld->name =OCIcolumnname($this->_queryID, $fieldOffset);
$fld->type = OCIcolumntype($this->_queryID, $fieldOffset);
$fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset);
if ($fld->type == 'NUMBER') {
switch($fld->type) {
case 'NUMBER':
$p = OCIColumnPrecision($this->_queryID, $fieldOffset);
$sc = OCIColumnScale($this->_queryID, $fieldOffset);
if ($p != 0 && $sc == 0) $fld->type = 'INT';
//echo " $this->name ($p.$sc) ";
}
break;
case 'CLOB':
case 'NCLOB':
case 'BLOB':
$fld->max_length = -1;
break;
}
return $fld;
}
/* For some reason, OCIcolumnname fails when called after _initrs() so we cache it */
function &FetchField($fieldOffset = -1)
function FetchField($fieldOffset = -1)
{
return $this->_fieldobjs[$fieldOffset];
}
@@ -1345,7 +1434,7 @@ class ADORecordset_oci8 extends ADORecordSet {
/*
# does not work as first record is retrieved in _initrs(), so is not included in GetArray()
function &GetArray($nRows = -1)
function GetArray($nRows = -1)
{
global $ADODB_OCI8_GETARRAY;
@@ -1364,7 +1453,7 @@ class ADORecordset_oci8 extends ADORecordSet {
if (ADODB_ASSOC_CASE != 2 || $this->databaseType != 'oci8') break;
$ncols = @OCIfetchstatement($this->_queryID, $assoc, 0, $nRows, OCI_FETCHSTATEMENT_BY_ROW);
$results =& array_merge(array($this->fields),$assoc);
$results = array_merge(array($this->fields),$assoc);
return $results;
default:
@@ -1372,16 +1461,16 @@ class ADORecordset_oci8 extends ADORecordSet {
}
}
$results =& ADORecordSet::GetArray($nRows);
$results = ADORecordSet::GetArray($nRows);
return $results;
} */
/* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */
function &GetArrayLimit($nrows,$offset=-1)
function GetArrayLimit($nrows,$offset=-1)
{
if ($offset <= 0) {
$arr =& $this->GetArray($nrows);
$arr = $this->GetArray($nrows);
return $arr;
}
$arr = array();

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
<?php
/**
* @version V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
* @version V5.06 16 Oct 2008 (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.
@@ -26,7 +26,7 @@ class ADODB_oci805 extends ADODB_oci8 {
$this->ADODB_oci8();
}
function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
{
// seems that oracle only supports 1 hint comment in 8i
if (strpos($sql,'/*+') !== false)

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim. All rights reserved.
V5.08 6 Apr 2009 (c) 2000-2009 John Lim. 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.
@@ -50,7 +50,7 @@ class ADODB_oci8po extends ADODB_oci8 {
}
// emulate handling of parameters ? ?, replacing with :bind0 :bind1
function _query($sql,$inputarr)
function _query($sql,$inputarr=false)
{
if (is_array($inputarr)) {
$i = 0;
@@ -98,11 +98,12 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
}
// lowercase field names...
function &_FetchField($fieldOffset = -1)
function _FetchField($fieldOffset = -1)
{
$fld = new ADOFieldObject;
$fieldOffset += 1;
$fld->name = strtolower(OCIcolumnname($this->_queryID, $fieldOffset));
$fld->name = OCIcolumnname($this->_queryID, $fieldOffset);
if (ADODB_ASSOC_CASE == 0) $fld->name = strtolower($fld->name);
$fld->type = OCIcolumntype($this->_queryID, $fieldOffset);
$fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset);
if ($fld->type == 'NUMBER') {
@@ -149,7 +150,7 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
}
/* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */
function &GetArrayLimit($nrows,$offset=-1)
function GetArrayLimit($nrows,$offset=-1)
{
if ($offset <= 0) {
$arr = $this->GetArray($nrows);

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -252,7 +252,7 @@ class ADODB_odbc extends ADOConnection {
if (!$rs) return false;
$rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
$arr =& $rs->GetArray();
$arr = $rs->GetArray();
$rs->Close();
//print_r($arr);
$arr2 = array();
@@ -264,7 +264,7 @@ class ADODB_odbc extends ADOConnection {
function &MetaTables($ttype=false)
function MetaTables($ttype=false)
{
global $ADODB_FETCH_MODE;
@@ -281,7 +281,7 @@ class ADODB_odbc extends ADOConnection {
}
$rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
$arr =& $rs->GetArray();
$arr = $rs->GetArray();
//print_r($arr);
$rs->Close();
@@ -370,7 +370,7 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/od
}
}
function &MetaColumns($table)
function MetaColumns($table)
{
global $ADODB_FETCH_MODE;
@@ -422,7 +422,7 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/od
}
if (empty($qid)) return $false;
$rs =& new ADORecordSet_odbc($qid);
$rs = new ADORecordSet_odbc($qid);
$ADODB_FETCH_MODE = $savem;
if (!$rs) return $false;
@@ -614,7 +614,7 @@ class ADORecordSet_odbc extends ADORecordSet {
// returns the field object
function &FetchField($fieldOffset = -1)
function FetchField($fieldOffset = -1)
{
$off=$fieldOffset+1; // offsets begin at 1
@@ -661,10 +661,10 @@ class ADORecordSet_odbc extends ADORecordSet {
}
// speed up SelectLimit() by switching to ADODB_FETCH_NUM as ADODB_FETCH_ASSOC is emulated
function &GetArrayLimit($nrows,$offset=-1)
function GetArrayLimit($nrows,$offset=-1)
{
if ($offset <= 0) {
$rs =& $this->GetArray($nrows);
$rs = $this->GetArray($nrows);
return $rs;
}
$savem = $this->fetchMode;
@@ -673,7 +673,7 @@ class ADORecordSet_odbc extends ADORecordSet {
$this->fetchMode = $savem;
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
}
$results = array();
@@ -700,7 +700,7 @@ class ADORecordSet_odbc extends ADORecordSet {
}
if ($rez) {
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
}
return true;
}
@@ -721,7 +721,7 @@ class ADORecordSet_odbc extends ADORecordSet {
}
if ($rez) {
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
}
return true;
}

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -140,7 +140,7 @@ class ADODB_ODBC_DB2 extends ADODB_odbc {
return $this->GetOne("select $flds from $tables where $where for update");
}
function &MetaTables($ttype=false,$showSchema=false, $qtable="%", $qschema="%")
function MetaTables($ttype=false,$showSchema=false, $qtable="%", $qschema="%")
{
global $ADODB_FETCH_MODE;
@@ -157,7 +157,7 @@ class ADODB_ODBC_DB2 extends ADODB_odbc {
}
$rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
$arr =& $rs->GetArray();
$arr = $rs->GetArray();
//print_r($arr);
$rs->Close();
@@ -184,7 +184,7 @@ class ADODB_ODBC_DB2 extends ADODB_odbc {
return $arr2;
}
function &MetaIndexes ($table, $primary = FALSE, $owner=false)
function MetaIndexes ($table, $primary = FALSE, $owner=false)
{
// save old fetch mode
global $ADODB_FETCH_MODE;
@@ -278,20 +278,20 @@ class ADODB_ODBC_DB2 extends ADODB_odbc {
}
function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputArr=false)
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputArr=false)
{
$nrows = (integer) $nrows;
if ($offset <= 0) {
// could also use " OPTIMIZE FOR $nrows ROWS "
if ($nrows >= 0) $sql .= " FETCH FIRST $nrows ROWS ONLY ";
$rs =& $this->Execute($sql,$inputArr);
$rs = $this->Execute($sql,$inputArr);
} else {
if ($offset > 0 && $nrows < 0);
else {
$nrows += $offset;
$sql .= " FETCH FIRST $nrows ROWS ONLY ";
}
$rs =& ADOConnection::SelectLimit($sql,-1,$offset,$inputArr);
$rs = ADOConnection::SelectLimit($sql,-1,$offset,$inputArr);
}
return $rs;

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -35,7 +35,7 @@ class ADODB_odbc_mssql extends ADODB_odbc {
var $substr = 'substring';
var $length = 'len';
var $ansiOuter = true; // for mssql7 or later
var $identitySQL = 'select @@IDENTITY'; // 'select SCOPE_IDENTITY'; # for mssql 2000
var $identitySQL = 'select @@identity'; // 'select SCOPE_IDENTITY'; # for mssql 2000
var $hasInsertID = true;
var $connectStmt = 'SET CONCAT_NULL_YIELDS_NULL OFF'; # When SET CONCAT_NULL_YIELDS_NULL is ON,
# concatenating a null value with a string yields a NULL result
@@ -50,12 +50,11 @@ class ADODB_odbc_mssql extends ADODB_odbc {
function ServerInfo()
{
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$save=$this->SetFetchMode(ADODB_FETCH_NUM);
$row = $this->GetRow("execute sp_server_info 2");
$ADODB_FETCH_MODE = $save;
$this->SetFetchMode($save);
if (!is_array($row)) return false;
@$arr['description'] = $row[2];
$arr['description'] = $row[2];
$arr['version'] = ADOConnection::_findvers($arr['description']);
return $arr;
}
@@ -93,7 +92,7 @@ from sysforeignkeys
where upper(object_name(fkeyid)) = $table
order by constraint_name, referenced_table_name, keyno";
$constraints =& $this->GetArray($sql);
$constraints = $this->GetArray($sql);
$ADODB_FETCH_MODE = $save;
@@ -115,14 +114,14 @@ order by constraint_name, referenced_table_name, keyno";
return $arr2;
}
function &MetaTables($ttype=false,$showSchema=false,$mask=false)
function MetaTables($ttype=false,$showSchema=false,$mask=false)
{
if ($mask) {$this->debug=1;
$save = $this->metaTablesSQL;
$mask = $this->qstr($mask);
$this->metaTablesSQL .= " AND name like $mask";
}
$ret =& ADOConnection::MetaTables($ttype,$showSchema);
$ret = ADOConnection::MetaTables($ttype,$showSchema);
if ($mask) {
$this->metaTablesSQL = $save;
@@ -130,14 +129,14 @@ order by constraint_name, referenced_table_name, keyno";
return $ret;
}
function &MetaColumns($table)
function MetaColumns($table)
{
$arr = ADOConnection::MetaColumns($table);
return $arr;
}
function &MetaIndexes($table,$primary=false)
function MetaIndexes($table,$primary=false)
{
$table = $this->qstr($table);
@@ -177,7 +176,7 @@ order by constraint_name, referenced_table_name, keyno";
return $indexes;
}
function _query($sql,$inputarr)
function _query($sql,$inputarr=false)
{
if (is_string($sql)) $sql = str_replace('||','+',$sql);
return ADODB_odbc::_query($sql,$inputarr);
@@ -196,7 +195,7 @@ order by constraint_name, referenced_table_name, keyno";
// "Stein-Aksel Basma" <basma@accelero.no>
// tested with MSSQL 2000
function &MetaPrimaryKeys($table)
function MetaPrimaryKeys($table)
{
global $ADODB_FETCH_MODE;
@@ -220,14 +219,14 @@ order by constraint_name, referenced_table_name, keyno";
return $false;
}
function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
{
if ($nrows > 0 && $offset <= 0) {
$sql = preg_replace(
'/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop." $nrows ",$sql);
$rs =& $this->Execute($sql,$inputarr);
$rs = $this->Execute($sql,$inputarr);
} else
$rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
$rs = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
return $rs;
}

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -36,7 +36,7 @@ class ADODB_odbc_oracle extends ADODB_odbc {
$this->ADODB_odbc();
}
function &MetaTables()
function MetaTables()
{
$false = false;
$rs = $this->Execute($this->metaTablesSQL);
@@ -50,7 +50,7 @@ class ADODB_odbc_oracle extends ADODB_odbc {
return $arr2;
}
function &MetaColumns($table)
function MetaColumns($table)
{
global $ADODB_FETCH_MODE;

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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. See License.txt.
@@ -45,16 +45,39 @@ class ADODB_odbtp extends ADOConnection{
function ErrorMsg()
{
if ($this->_errorMsg !== false) return $this->_errorMsg;
if (empty($this->_connectionID)) return @odbtp_last_error();
return @odbtp_last_error($this->_connectionID);
}
function ErrorNo()
{
if ($this->_errorCode !== false) return $this->_errorCode;
if (empty($this->_connectionID)) return @odbtp_last_error_state();
return @odbtp_last_error_state($this->_connectionID);
}
/*
function DBDate($d,$isfld=false)
{
if (empty($d) && $d !== 0) return 'null';
if ($isfld) return "convert(date, $d, 120)";
if (is_string($d)) $d = ADORecordSet::UnixDate($d);
$d = adodb_date($this->fmtDate,$d);
return "convert(date, $d, 120)";
}
function DBTimeStamp($d,$isfld=false)
{
if (empty($d) && $d !== 0) return 'null';
if ($isfld) return "convert(datetime, $d, 120)";
if (is_string($d)) $d = ADORecordSet::UnixDate($d);
$d = adodb_date($this->fmtDate,$d);
return "convert(datetime, $d, 120)";
}
*/
function _insertid()
{
// SCOPE_IDENTITY()
@@ -192,7 +215,7 @@ class ADODB_odbtp extends ADOConnection{
$this->_canSelectDb = true;
$this->substr = "substring";
$this->length = 'len';
$this->identitySQL = 'select @@IDENTITY';
$this->identitySQL = 'select SCOPE_IDENTITY()';
$this->metaDatabasesSQL = "select name from master..sysdatabases where name <> 'master'";
$this->_canPrepareSP = true;
break;
@@ -240,7 +263,7 @@ class ADODB_odbtp extends ADOConnection{
$this->rightOuter = '=*';
$this->hasInsertID = true;
$this->hasTransactions = true;
$this->identitySQL = 'select @@IDENTITY';
$this->identitySQL = 'select SCOPE_IDENTITY()';
break;
default:
$this->databaseType = 'odbtp';
@@ -273,7 +296,7 @@ class ADODB_odbtp extends ADOConnection{
return true;
}
function &MetaTables($ttype='',$showSchema=false,$mask=false)
function MetaTables($ttype='',$showSchema=false,$mask=false)
{
global $ADODB_FETCH_MODE;
@@ -281,7 +304,7 @@ class ADODB_odbtp extends ADOConnection{
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== false) $savefm = $this->SetFetchMode(false);
$arr =& $this->GetArray("||SQLTables||||$ttype");
$arr = $this->GetArray("||SQLTables||||$ttype");
if (isset($savefm)) $this->SetFetchMode($savefm);
$ADODB_FETCH_MODE = $savem;
@@ -295,7 +318,7 @@ class ADODB_odbtp extends ADOConnection{
return $arr2;
}
function &MetaColumns($table,$upper=true)
function MetaColumns($table,$upper=true)
{
global $ADODB_FETCH_MODE;
@@ -341,13 +364,13 @@ class ADODB_odbtp extends ADOConnection{
return $retarr;
}
function &MetaPrimaryKeys($table, $owner='')
function MetaPrimaryKeys($table, $owner='')
{
global $ADODB_FETCH_MODE;
$savem = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$arr =& $this->GetArray("||SQLPrimaryKeys||$owner|$table");
$arr = $this->GetArray("||SQLPrimaryKeys||$owner|$table");
$ADODB_FETCH_MODE = $savem;
//print_r($arr);
@@ -358,13 +381,13 @@ class ADODB_odbtp extends ADOConnection{
return $arr2;
}
function &MetaForeignKeys($table, $owner='', $upper=false)
function MetaForeignKeys($table, $owner='', $upper=false)
{
global $ADODB_FETCH_MODE;
$savem = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$constraints =& $this->GetArray("||SQLForeignKeys|||||$owner|$table");
$constraints = $this->GetArray("||SQLForeignKeys|||||$owner|$table");
$ADODB_FETCH_MODE = $savem;
$arr = false;
@@ -424,19 +447,23 @@ class ADODB_odbtp extends ADOConnection{
return $ret;
}
function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
{
// TOP requires ORDER BY for Visual FoxPro
if( $this->odbc_driver == ODB_DRIVER_FOXPRO ) {
if (!preg_match('/ORDER[ \t\r\n]+BY/is',$sql)) $sql .= ' ORDER BY 1';
}
$ret =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
$ret = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
return $ret;
}
function Prepare($sql)
{
if (! $this->_bindInputArray) return $sql; // no binding
$this->_errorMsg = false;
$this->_errorCode = false;
$stmt = @odbtp_prepare($sql,$this->_connectionID);
if (!$stmt) {
// print "Prepare Error for ($sql) ".$this->ErrorMsg()."<br>";
@@ -449,6 +476,9 @@ class ADODB_odbtp extends ADOConnection{
{
if (!$this->_canPrepareSP) return $sql; // Can't prepare procedures
$this->_errorMsg = false;
$this->_errorCode = false;
$stmt = @odbtp_prepare_proc($sql,$this->_connectionID);
if (!$stmt) return false;
return array($sql,$stmt);
@@ -511,6 +541,56 @@ class ADODB_odbtp extends ADOConnection{
return @odbtp_execute( $stmt ) != false;
}
function MetaIndexes($table,$primary=false)
{
switch ( $this->odbc_driver) {
case ODB_DRIVER_MSSQL:
return $this->MetaIndexes_mssql($table, $primary);
default:
return array();
}
}
function MetaIndexes_mssql($table,$primary=false)
{
$table = strtolower($this->qstr($table));
$sql = "SELECT i.name AS ind_name, C.name AS col_name, USER_NAME(O.uid) AS Owner, c.colid, k.Keyno,
CASE WHEN I.indid BETWEEN 1 AND 254 AND (I.status & 2048 = 2048 OR I.Status = 16402 AND O.XType = 'V') THEN 1 ELSE 0 END AS IsPK,
CASE WHEN I.status & 2 = 2 THEN 1 ELSE 0 END AS IsUnique
FROM dbo.sysobjects o INNER JOIN dbo.sysindexes I ON o.id = i.id
INNER JOIN dbo.sysindexkeys K ON I.id = K.id AND I.Indid = K.Indid
INNER JOIN dbo.syscolumns c ON K.id = C.id AND K.colid = C.Colid
WHERE LEFT(i.name, 8) <> '_WA_Sys_' AND o.status >= 0 AND lower(O.Name) = $table
ORDER BY O.name, I.Name, K.keyno";
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== FALSE) {
$savem = $this->SetFetchMode(FALSE);
}
$rs = $this->Execute($sql);
if (isset($savem)) {
$this->SetFetchMode($savem);
}
$ADODB_FETCH_MODE = $save;
if (!is_object($rs)) {
return FALSE;
}
$indexes = array();
while ($row = $rs->FetchRow()) {
if ($primary && !$row[5]) continue;
$indexes[$row[0]]['unique'] = $row[6];
$indexes[$row[0]]['columns'][] = $row[1];
}
return $indexes;
}
function IfNull( $field, $ifNull )
{
switch( $this->odbc_driver ) {
@@ -526,6 +606,9 @@ class ADODB_odbtp extends ADOConnection{
{
global $php_errormsg;
$this->_errorMsg = false;
$this->_errorCode = false;
if ($inputarr) {
if (is_array($sql)) {
$stmtid = $sql[1];
@@ -537,10 +620,20 @@ class ADODB_odbtp extends ADOConnection{
}
}
$num_params = @odbtp_num_params( $stmtid );
/*
for( $param = 1; $param <= $num_params; $param++ ) {
@odbtp_input( $stmtid, $param );
@odbtp_set( $stmtid, $param, $inputarr[$param-1] );
}*/
$param = 1;
foreach($inputarr as $v) {
@odbtp_input( $stmtid, $param );
@odbtp_set( $stmtid, $param, $v );
$param += 1;
if ($param > $num_params) break;
}
if (!@odbtp_execute($stmtid) ) {
return false;
}
@@ -602,7 +695,7 @@ class ADORecordSet_odbtp extends ADORecordSet {
}
}
function &FetchField($fieldOffset = 0)
function FetchField($fieldOffset = 0)
{
$off=$fieldOffset; // offsets begin at 0
$o= new ADOFieldObject();

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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. See License.txt.

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -248,7 +248,7 @@ class ADORecordset_oracle extends ADORecordSet {
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. */
function &FetchField($fieldOffset = -1)
function FetchField($fieldOffset = -1)
{
$fld = new ADOFieldObject;
$fld->name = ora_columnname($this->_queryID, $fieldOffset);

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -64,39 +64,7 @@ function adodb_pdo_type($t)
class ADODB_pdo_base extends ADODB_pdo {
var $sysDate = "'?'";
var $sysTimeStamp = "'?'";
function _init($parentDriver)
{
$parentDriver->_bindInputArray = true;
#$parentDriver->_connectionID->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true);
}
function ServerInfo()
{
return ADOConnection::ServerInfo();
}
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
{
$ret = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
return $ret;
}
function MetaTables()
{
return false;
}
function MetaColumns()
{
return false;
}
}
class ADODB_pdo extends ADOConnection {
@@ -124,7 +92,7 @@ class ADODB_pdo extends ADOConnection {
function _UpdatePDO()
{
$d = &$this->_driver;
$d = $this->_driver;
$this->fmtDate = $d->fmtDate;
$this->fmtTimeStamp = $d->fmtTimeStamp;
$this->replaceQuote = $d->replaceQuote;
@@ -147,7 +115,7 @@ class ADODB_pdo extends ADOConnection {
if (!empty($this->_driver->_hasdual)) $sql = "select $this->sysTimeStamp from dual";
else $sql = "select $this->sysTimeStamp";
$rs =& $this->_Execute($sql);
$rs = $this->_Execute($sql);
if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields));
return false;
@@ -190,6 +158,7 @@ class ADODB_pdo extends ADOConnection {
case 'mysql':
case 'pgsql':
case 'mssql':
case 'sqlite':
include_once(ADODB_DIR.'/drivers/adodb-pdo_'.$this->dsnType.'.inc.php');
break;
}
@@ -206,6 +175,15 @@ class ADODB_pdo extends ADOConnection {
return false;
}
function Concat()
{
$args = func_get_args();
if(method_exists($this->_driver, 'Concat'))
return call_user_func_array(array($this->_driver, 'Concat'), $args);
return call_user_func_array(array($this,'parent::Concat'), $args);
}
// returns true or false
function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
{
@@ -248,6 +226,10 @@ class ADODB_pdo extends ADOConnection {
else $obj->bindParam($name, $var);
}
function OffsetDate($dayFraction,$date=false)
{
return $this->_driver->OffsetDate($dayFraction,$date);
}
function ErrorMsg()
{
@@ -280,8 +262,19 @@ class ADODB_pdo extends ADOConnection {
return $err;
}
function SetTransactionMode($transaction_mode)
{
if(method_exists($this->_driver, 'SetTransactionMode'))
return $this->_driver->SetTransactionMode($transaction_mode);
return parent::SetTransactionMode($seqname);
}
function BeginTrans()
{
if(method_exists($this->_driver, 'BeginTrans'))
return $this->_driver->BeginTrans();
if (!$this->hasTransactions) return false;
if ($this->transOff) return true;
$this->transCnt += 1;
@@ -292,6 +285,9 @@ class ADODB_pdo extends ADOConnection {
function CommitTrans($ok=true)
{
if(method_exists($this->_driver, 'CommitTrans'))
return $this->_driver->CommitTrans($ok);
if (!$this->hasTransactions) return false;
if ($this->transOff) return true;
if (!$ok) return $this->RollbackTrans();
@@ -305,6 +301,9 @@ class ADODB_pdo extends ADOConnection {
function RollbackTrans()
{
if(method_exists($this->_driver, 'RollbackTrans'))
return $this->_driver->RollbackTrans();
if (!$this->hasTransactions) return false;
if ($this->transOff) return true;
if ($this->transCnt) $this->transCnt -= 1;
@@ -331,6 +330,30 @@ class ADODB_pdo extends ADOConnection {
return $obj;
}
function CreateSequence($seqname='adodbseq',$startID=1)
{
if(method_exists($this->_driver, 'CreateSequence'))
return $this->_driver->CreateSequence($seqname, $startID);
return parent::CreateSequence($seqname, $startID);
}
function DropSequence($seqname='adodbseq')
{
if(method_exists($this->_driver, 'DropSequence'))
return $this->_driver->DropSequence($seqname);
return parent::DropSequence($seqname);
}
function GenID($seqname='adodbseq',$startID=1)
{
if(method_exists($this->_driver, 'GenID'))
return $this->_driver->GenID($seqname, $startID);
return parent::GenID($seqname, $startID);
}
/* returns queryID or false */
function _query($sql,$inputarr=false)
@@ -390,6 +413,40 @@ class ADODB_pdo extends ADOConnection {
}
}
class ADODB_pdo_base extends ADODB_pdo {
var $sysDate = "'?'";
var $sysTimeStamp = "'?'";
function _init($parentDriver)
{
$parentDriver->_bindInputArray = true;
#$parentDriver->_connectionID->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true);
}
function ServerInfo()
{
return ADOConnection::ServerInfo();
}
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
{
$ret = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
return $ret;
}
function MetaTables()
{
return false;
}
function MetaColumns()
{
return false;
}
}
class ADOPDOStatement {
var $databaseType = "pdo";
@@ -506,7 +563,7 @@ class ADORecordSet_pdo extends ADORecordSet {
}
// returns the field object
function &FetchField($fieldOffset = -1)
function FetchField($fieldOffset = -1)
{
$off=$fieldOffset+1; // offsets begin at 1

View File

@@ -2,7 +2,7 @@
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -47,12 +47,12 @@ class ADODB_pdo_mssql extends ADODB_pdo {
$this->Execute("SET TRANSACTION ".$transaction_mode);
}
function MetaTables()
function MetaTables($ttype=false,$showSchema=false,$mask=false)
{
return false;
}
function MetaColumns()
function MetaColumns($table,$normalize=true)
{
return false;
}

View File

@@ -2,7 +2,7 @@
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -15,13 +15,17 @@ class ADODB_pdo_mysql extends ADODB_pdo {
var $metaColumnsSQL = "SHOW COLUMNS FROM `%s`";
var $sysDate = 'CURDATE()';
var $sysTimeStamp = 'NOW()';
var $hasGenID = true;
var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);";
var $_dropSeqSQL = "drop table %s";
var $fmtTimeStamp = "'Y-m-d, H:i:s'";
var $nameQuote = '`';
function _init($parentDriver)
{
$parentDriver->hasTransactions = false;
$parentDriver->_bindInputArray = false;
#$parentDriver->_bindInputArray = false;
$parentDriver->hasInsertID = true;
$parentDriver->_connectionID->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true);
}
@@ -37,6 +41,16 @@ class ADODB_pdo_mysql extends ADODB_pdo {
// return "from_unixtime(unix_timestamp($date)+$fraction)";
}
function Concat()
{
$s = "";
$arr = func_get_args();
// suggestion by andrew005#mnogo.ru
$s = implode(',',$arr);
if (strlen($s) > 0) return "CONCAT($s)"; return '';
}
function ServerInfo()
{
$arr['description'] = ADOConnection::GetOne("select version()");
@@ -44,7 +58,7 @@ class ADODB_pdo_mysql extends ADODB_pdo {
return $arr;
}
function &MetaTables($ttype=false,$showSchema=false,$mask=false)
function MetaTables($ttype=false,$showSchema=false,$mask=false)
{
$save = $this->metaTablesSQL;
if ($showSchema && is_string($showSchema)) {
@@ -55,7 +69,7 @@ class ADODB_pdo_mysql extends ADODB_pdo {
$mask = $this->qstr($mask);
$this->metaTablesSQL .= " like $mask";
}
$ret =& ADOConnection::MetaTables($ttype,$showSchema);
$ret = ADOConnection::MetaTables($ttype,$showSchema);
$this->metaTablesSQL = $save;
return $ret;
@@ -72,7 +86,7 @@ class ADODB_pdo_mysql extends ADODB_pdo {
$this->Execute("SET SESSION TRANSACTION ".$transaction_mode);
}
function &MetaColumns($table)
function MetaColumns($table,$normalize=true)
{
$this->_findschema($table,$schema);
if ($schema) {
@@ -152,16 +166,16 @@ class ADODB_pdo_mysql extends ADODB_pdo {
// parameters use PostgreSQL convention, not MySQL
function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0)
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0)
{
$offsetStr =($offset>=0) ? "$offset," : '';
// jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220
if ($nrows < 0) $nrows = '18446744073709551615';
if ($secs)
$rs =& $this->CacheExecute($secs,$sql." LIMIT $offsetStr$nrows",$inputarr);
$rs = $this->CacheExecute($secs,$sql." LIMIT $offsetStr$nrows",$inputarr);
else
$rs =& $this->Execute($sql." LIMIT $offsetStr$nrows",$inputarr);
$rs = $this->Execute($sql." LIMIT $offsetStr$nrows",$inputarr);
return $rs;
}
}

View File

@@ -2,7 +2,7 @@
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -32,14 +32,14 @@ class ADODB_pdo_oci extends ADODB_pdo_base {
}
}
function &MetaTables($ttype=false,$showSchema=false,$mask=false)
function MetaTables($ttype=false,$showSchema=false,$mask=false)
{
if ($mask) {
$save = $this->metaTablesSQL;
$mask = $this->qstr(strtoupper($mask));
$this->metaTablesSQL .= " AND table_name like $mask";
}
$ret =& ADOConnection::MetaTables($ttype,$showSchema);
$ret = ADOConnection::MetaTables($ttype,$showSchema);
if ($mask) {
$this->metaTablesSQL = $save;
@@ -47,7 +47,7 @@ class ADODB_pdo_oci extends ADODB_pdo_base {
return $ret;
}
function &MetaColumns($table)
function MetaColumns($table,$normalize=true)
{
global $ADODB_FETCH_MODE;

View File

@@ -1,7 +1,7 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -11,11 +11,11 @@ V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights rese
class ADODB_pdo_pgsql extends ADODB_pdo {
var $metaDatabasesSQL = "select datname from pg_database where datname not in ('template0','template1') order by 1";
var $metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg_%'
var $metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%'
and tablename not in ('sql_features', 'sql_implementation_info', 'sql_languages',
'sql_packages', 'sql_sizing', 'sql_sizing_profiles')
union
select viewname,'V' from pg_views where viewname not like 'pg_%'";
select viewname,'V' from pg_views where viewname not like 'pg\_%'";
//"select tablename from pg_tables where tablename not like 'pg_%' order by 1";
var $isoDates = true; // accepts dates in ISO format
var $sysDate = "CURRENT_DATE";
@@ -69,26 +69,26 @@ WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s'))
return $arr;
}
function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
{
$offsetStr = ($offset >= 0) ? " OFFSET $offset" : '';
$limitStr = ($nrows >= 0) ? " LIMIT $nrows" : '';
if ($secs2cache)
$rs =& $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr);
$rs = $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr);
else
$rs =& $this->Execute($sql."$limitStr$offsetStr",$inputarr);
$rs = $this->Execute($sql."$limitStr$offsetStr",$inputarr);
return $rs;
}
function &MetaTables($ttype=false,$showSchema=false,$mask=false)
function MetaTables($ttype=false,$showSchema=false,$mask=false)
{
$info = $this->ServerInfo();
if ($info['version'] >= 7.3) {
$this->metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg_%'
$this->metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%'
and schemaname not in ( 'pg_catalog','information_schema')
union
select viewname,'V' from pg_views where viewname not like 'pg_%' and schemaname not in ( 'pg_catalog','information_schema') ";
select viewname,'V' from pg_views where viewname not like 'pg\_%' and schemaname not in ( 'pg_catalog','information_schema') ";
}
if ($mask) {
$save = $this->metaTablesSQL;
@@ -104,7 +104,7 @@ select tablename,'T' from pg_tables where tablename like $mask
union
select viewname,'V' from pg_views where viewname like $mask";
}
$ret =& ADOConnection::MetaTables($ttype,$showSchema);
$ret = ADOConnection::MetaTables($ttype,$showSchema);
if ($mask) {
$this->metaTablesSQL = $save;
@@ -112,7 +112,7 @@ select viewname,'V' from pg_views where viewname like $mask";
return $ret;
}
function &MetaColumns($table,$normalize=true)
function MetaColumns($table,$normalize=true)
{
global $ADODB_FETCH_MODE;
@@ -125,8 +125,8 @@ select viewname,'V' from pg_views where viewname like $mask";
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
if ($schema) $rs =& $this->Execute(sprintf($this->metaColumnsSQL1,$table,$table,$schema));
else $rs =& $this->Execute(sprintf($this->metaColumnsSQL,$table,$table));
if ($schema) $rs = $this->Execute(sprintf($this->metaColumnsSQL1,$table,$table,$schema));
else $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table,$table));
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
@@ -144,7 +144,7 @@ select viewname,'V' from pg_views where viewname like $mask";
$rskey = $this->Execute(sprintf($this->metaKeySQL,($table)));
// fetch all result in once for performance.
$keys =& $rskey->GetArray();
$keys = $rskey->GetArray();
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;

View File

@@ -0,0 +1,190 @@
<?php
/*
V5.08 6 Apr 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. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net
Thanks Diogo Toscano (diogo#scriptcase.net) for the code.
And also Sid Dunayer [sdunayer#interserv.com] for extensive fixes.
*/
class ADODB_pdo_sqlite extends ADODB_pdo {
var $metaTablesSQL = "SELECT name FROM sqlite_master WHERE type='table'";
var $sysDate = 'current_date';
var $sysTimeStamp = 'current_timestamp';
var $nameQuote = '`';
var $replaceQuote = "''";
var $hasGenID = true;
var $_genIDSQL = "UPDATE %s SET id=id+1 WHERE id=%s";
var $_genSeqSQL = "CREATE TABLE %s (id integer)";
var $_genSeqCountSQL = 'SELECT COUNT(*) FROM %s';
var $_genSeq2SQL = 'INSERT INTO %s VALUES(%s)';
var $_dropSeqSQL = 'DROP TABLE %s';
var $concat_operator = '||';
var $pdoDriver = false;
function _init($parentDriver)
{
$this->pdoDriver = $parentDriver;
$parentDriver->_bindInputArray = true;
$parentDriver->hasTransactions = true;
$parentDriver->hasInsertID = true;
}
function ServerInfo()
{
$parent = $this->pdoDriver;
@($ver = array_pop($parent->GetCol("SELECT sqlite_version()")));
@($end = array_pop($parent->GetCol("PRAGMA encoding")));
$arr['version'] = $ver;
$arr['description'] = 'SQLite ';
$arr['encoding'] = $enc;
return $arr;
}
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
{
$parent = $this->pdoDriver;
$offsetStr = ($offset >= 0) ? " OFFSET $offset" : '';
$limitStr = ($nrows >= 0) ? " LIMIT $nrows" : ($offset >= 0 ? ' LIMIT 999999999' : '');
if ($secs2cache)
$rs = $parent->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr);
else
$rs = $parent->Execute($sql."$limitStr$offsetStr",$inputarr);
return $rs;
}
function GenID($seq='adodbseq',$start=1)
{
$parent = $this->pdoDriver;
// if you have to modify the parameter below, your database is overloaded,
// or you need to implement generation of id's yourself!
$MAXLOOPS = 100;
while (--$MAXLOOPS>=0) {
@($num = array_pop($parent->GetCol("SELECT id FROM {$seq}")));
if ($num === false || !is_numeric($num)) {
@$parent->Execute(sprintf($this->_genSeqSQL ,$seq));
$start -= 1;
$num = '0';
$cnt = $parent->GetOne(sprintf($this->_genSeqCountSQL,$seq));
if (!$cnt) {
$ok = $parent->Execute(sprintf($this->_genSeq2SQL,$seq,$start));
}
if (!$ok) return false;
}
$parent->Execute(sprintf($this->_genIDSQL,$seq,$num));
if ($parent->affected_rows() > 0) {
$num += 1;
$parent->genID = intval($num);
return intval($num);
}
}
if ($fn = $parent->raiseErrorFn) {
$fn($parent->databaseType,'GENID',-32000,"Unable to generate unique id after $MAXLOOPS attempts",$seq,$num);
}
return false;
}
function CreateSequence($seqname='adodbseq',$start=1)
{
$parent = $this->pdoDriver;
$ok = $parent->Execute(sprintf($this->_genSeqSQL,$seqname));
if (!$ok) return false;
$start -= 1;
return $parent->Execute("insert into $seqname values($start)");
}
function SetTransactionMode($transaction_mode)
{
$parent = $this->pdoDriver;
$parent->_transmode = strtoupper($transaction_mode);
}
function BeginTrans()
{
$parent = $this->pdoDriver;
if ($parent->transOff) return true;
$parent->transCnt += 1;
$parent->_autocommit = false;
return $parent->Execute("BEGIN {$parent->_transmode}");
}
function CommitTrans($ok=true)
{
$parent = $this->pdoDriver;
if ($parent->transOff) return true;
if (!$ok) return $parent->RollbackTrans();
if ($parent->transCnt) $parent->transCnt -= 1;
$parent->_autocommit = true;
$ret = $parent->Execute('COMMIT');
return $ret;
}
function RollbackTrans()
{
$parent = $this->pdoDriver;
if ($parent->transOff) return true;
if ($parent->transCnt) $parent->transCnt -= 1;
$parent->_autocommit = true;
$ret = $parent->Execute('ROLLBACK');
return $ret;
}
// mark newnham
function MetaColumns($tab,$normalize=true))
{
global $ADODB_FETCH_MODE;
$parent = $this->pdoDriver;
$false = false;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
if ($parent->fetchMode !== false) $savem = $parent->SetFetchMode(false);
$rs = $parent->Execute("PRAGMA table_info('$tab')");
if (isset($savem)) $parent->SetFetchMode($savem);
if (!$rs) {
$ADODB_FETCH_MODE = $save;
return $false;
}
$arr = array();
while ($r = $rs->FetchRow()) {
$type = explode('(',$r['type']);
$size = '';
if (sizeof($type)==2)
$size = trim($type[1],')');
$fn = strtoupper($r['name']);
$fld = new ADOFieldObject;
$fld->name = $r['name'];
$fld->type = $type[0];
$fld->max_length = $size;
$fld->not_null = $r['notnull'];
$fld->primary_key = $r['pk'];
$fld->default_value = $r['dflt_value'];
$fld->scale = 0;
if ($save == ADODB_FETCH_NUM) $arr[] = $fld;
else $arr[strtoupper($fld->name)] = $fld;
}
$rs->Close();
$ADODB_FETCH_MODE = $save;
return $arr;
}
function MetaTables($ttype=false,$showSchema=false,$mask=false)
{
$parent = $this->pdoDriver;
return $parent->GetCol($this->metaTablesSQL);
}
}
?>

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -159,6 +159,7 @@ a different OID if a database must be reloaded. */
// to really return the id, we need the table and column-name, else we can only return the oid != id
return empty($table) || empty($column) ? $oid : $this->GetOne("SELECT CURRVAL('".$table."_".$column."_seq')");
}
// I get this error with PHP before 4.0.6 - jlim
// Warning: This compilation does not support pg_cmdtuples() in adodb-postgres.inc.php on line 44
function _affectedrows()
@@ -200,7 +201,7 @@ a different OID if a database must be reloaded. */
return @pg_Exec($this->_connectionID, "rollback");
}
function &MetaTables($ttype=false,$showSchema=false,$mask=false)
function MetaTables($ttype=false,$showSchema=false,$mask=false)
{
$info = $this->ServerInfo();
if ($info['version'] >= 7.3) {
@@ -223,7 +224,7 @@ select tablename,'T' from pg_tables where tablename like $mask
union
select viewname,'V' from pg_views where viewname like $mask";
}
$ret =& ADOConnection::MetaTables($ttype,$showSchema);
$ret = ADOConnection::MetaTables($ttype,$showSchema);
if ($mask) {
$this->metaTablesSQL = $save;
@@ -235,6 +236,8 @@ select viewname,'V' from pg_views where viewname like $mask";
// if magic quotes disabled, use pg_escape_string()
function qstr($s,$magic_quotes=false)
{
if (is_bool($s)) return $s ? 'true' : 'false';
if (!$magic_quotes) {
if (ADODB_PHPVER >= 0x5200) {
return "'".pg_escape_string($this->_connectionID,$s)."'";
@@ -463,7 +466,7 @@ select viewname,'V' from pg_views where viewname like $mask";
// for schema support, pass in the $table param "$schema.$tabname".
// converts field names to lowercase, $upper is ignored
// see http://phplens.com/lens/lensforum/msgs.php?id=14018 for more info
function &MetaColumns($table,$normalize=true)
function MetaColumns($table,$normalize=true)
{
global $ADODB_FETCH_MODE;
@@ -477,8 +480,8 @@ select viewname,'V' from pg_views where viewname like $mask";
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
if ($schema) $rs =& $this->Execute(sprintf($this->metaColumnsSQL1,$table,$table,$schema));
else $rs =& $this->Execute(sprintf($this->metaColumnsSQL,$table,$table));
if ($schema) $rs = $this->Execute(sprintf($this->metaColumnsSQL1,$table,$table,$schema));
else $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table,$table));
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
@@ -491,11 +494,11 @@ select viewname,'V' from pg_views where viewname like $mask";
// LEFT JOIN would have been much more elegant, but postgres does
// not support OUTER JOINS. So here is the clumsy way.
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$this->fetchMode = ADODB_FETCH_ASSOC;
$rskey = $this->Execute(sprintf($this->metaKeySQL,($table)));
// fetch all result in once for performance.
$keys =& $rskey->GetArray();
$keys = $rskey->GetArray();
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
@@ -505,7 +508,7 @@ select viewname,'V' from pg_views where viewname like $mask";
$rsdefa = array();
if (!empty($this->metaDefaultsSQL)) {
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$this->fetchMode = ADODB_FETCH_ASSOC;
$sql = sprintf($this->metaDefaultsSQL, ($table));
$rsdef = $this->Execute($sql);
if (isset($savem)) $this->SetFetchMode($savem);
@@ -577,7 +580,7 @@ select viewname,'V' from pg_views where viewname like $mask";
}
function &MetaIndexes ($table, $primary = FALSE)
function MetaIndexes ($table, $primary = FALSE)
{
global $ADODB_FETCH_MODE;
@@ -712,7 +715,7 @@ WHERE (c2.relname=\'%s\' or c2.relname=lower(\'%s\'))';
// returns queryID or false
function _query($sql,$inputarr)
function _query($sql,$inputarr=false)
{
$this->_errorMsg = false;
if ($inputarr) {
@@ -885,10 +888,10 @@ class ADORecordSet_postgres64 extends ADORecordSet{
$this->ADORecordSet($queryID);
}
function &GetRowAssoc($upper=true)
function GetRowAssoc($upper=true)
{
if ($this->fetchMode == PGSQL_ASSOC && !$upper) return $this->fields;
$row =& ADORecordSet::GetRowAssoc($upper);
$row = ADORecordSet::GetRowAssoc($upper);
return $row;
}
@@ -924,7 +927,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{
return $this->fields[$this->bind[strtoupper($colname)]];
}
function &FetchField($off = 0)
function FetchField($off = 0)
{
// offsets begin at 0
@@ -942,6 +945,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{
function _decode($blob)
{
if ($blob === NULL) return NULL;
eval('$realblob="'.adodb_str_replace(array('"','$'),array('\"','\$'),$blob).'";');
return $realblob;
}
@@ -1060,4 +1064,4 @@ class ADORecordSet_postgres64 extends ADORecordSet{
}
}
?>
?>

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -34,14 +34,14 @@ class ADODB_postgres7 extends ADODB_postgres64 {
// the following should be compat with postgresql 7.2,
// which makes obsolete the LIMIT limit,offset syntax
function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
{
$offsetStr = ($offset >= 0) ? " OFFSET ".((integer)$offset) : '';
$limitStr = ($nrows >= 0) ? " LIMIT ".((integer)$nrows) : '';
if ($secs2cache)
$rs =& $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr);
$rs = $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr);
else
$rs =& $this->Execute($sql."$limitStr$offsetStr",$inputarr);
$rs = $this->Execute($sql."$limitStr$offsetStr",$inputarr);
return $rs;
}
@@ -56,9 +56,58 @@ class ADODB_postgres7 extends ADODB_postgres64 {
}
*/
// from Edward Jaramilla, improved version - works on pg 7.4
/*
I discovered that the MetaForeignKeys method no longer worked for Postgres 8.3.
I went ahead and modified it to work for both 8.2 and 8.3.
Please feel free to include this change in your next release of adodb.
William Kolodny [William.Kolodny#gt-t.net]
*/
function MetaForeignKeys($table, $owner=false, $upper=false)
{
$sql="
SELECT fum.ftblname AS lookup_table, split_part(fum.rf, ')'::text, 1) AS lookup_field,
fum.ltable AS dep_table, split_part(fum.lf, ')'::text, 1) AS dep_field
FROM (
SELECT fee.ltable, fee.ftblname, fee.consrc, split_part(fee.consrc,'('::text, 2) AS lf,
split_part(fee.consrc, '('::text, 3) AS rf
FROM (
SELECT foo.relname AS ltable, foo.ftblname,
pg_get_constraintdef(foo.oid) AS consrc
FROM (
SELECT c.oid, c.conname AS name, t.relname, ft.relname AS ftblname
FROM pg_constraint c
JOIN pg_class t ON (t.oid = c.conrelid)
JOIN pg_class ft ON (ft.oid = c.confrelid)
JOIN pg_namespace nft ON (nft.oid = ft.relnamespace)
LEFT JOIN pg_description ds ON (ds.objoid = c.oid)
JOIN pg_namespace n ON (n.oid = t.relnamespace)
WHERE c.contype = 'f'::\"char\"
ORDER BY t.relname, n.nspname, c.conname, c.oid
) foo
) fee) fum
WHERE fum.ltable='".strtolower($table)."'
ORDER BY fum.ftblname, fum.ltable, split_part(fum.lf, ')'::text, 1)
";
$rs = $this->Execute($sql);
if (!$rs || $rs->EOF) return false;
$a = array();
while (!$rs->EOF) {
if ($upper) {
$a[strtoupper($rs->Fields('lookup_table'))][] = strtoupper(str_replace('"','',$rs->Fields('dep_field').'='.$rs->Fields('lookup_field')));
} else {
$a[$rs->Fields('lookup_table')][] = str_replace('"','',$rs->Fields('dep_field').'='.$rs->Fields('lookup_field'));
}
$rs->MoveNext();
}
return $a;
}
// from Edward Jaramilla, improved version - works on pg 7.4
function _old_MetaForeignKeys($table, $owner=false, $upper=false)
{
$sql = 'SELECT t.tgargs as args
FROM
@@ -72,11 +121,11 @@ class ADODB_postgres7 extends ADODB_postgres64 {
ORDER BY
t.tgrelid';
$rs =& $this->Execute($sql);
$rs = $this->Execute($sql);
if (!$rs || $rs->EOF) return false;
$arr =& $rs->GetArray();
$arr = $rs->GetArray();
$a = array();
foreach($arr as $v) {
$data = explode(chr(0), $v['args']);
@@ -91,7 +140,7 @@ class ADODB_postgres7 extends ADODB_postgres64 {
return $a;
}
function _query($sql,$inputarr)
function _query($sql,$inputarr=false)
{
if (! $this->_bindInputArray) {
// We don't have native support for parameterized queries, so let's emulate it at the parent

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -53,7 +53,7 @@ class ADODB_SAPDB extends ADODB_odbc {
return $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table AND mode='KEY' ORDER BY pos");
}
function &MetaIndexes ($table, $primary = FALSE)
function MetaIndexes ($table, $primary = FALSE)
{
$table = $this->Quote(strtoupper($table));
@@ -92,7 +92,7 @@ class ADODB_SAPDB extends ADODB_odbc {
return $indexes;
}
function &MetaColumns ($table)
function MetaColumns ($table)
{
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;

View File

@@ -1,6 +1,6 @@
<?php
/*
version V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights
version V5.06 16 Oct 2008 (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,

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -78,7 +78,7 @@ class ADODB_sqlite extends ADOConnection {
}
// mark newnham
function &MetaColumns($tab)
function MetaColumns($tab)
{
global $ADODB_FETCH_MODE;
$false = false;
@@ -190,14 +190,14 @@ class ADODB_sqlite extends ADOConnection {
return $rez;
}
function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
{
$offsetStr = ($offset >= 0) ? " OFFSET $offset" : '';
$limitStr = ($nrows >= 0) ? " LIMIT $nrows" : ($offset >= 0 ? ' LIMIT 999999999' : '');
if ($secs2cache)
$rs =& $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr);
$rs = $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr);
else
$rs =& $this->Execute($sql."$limitStr$offsetStr",$inputarr);
$rs = $this->Execute($sql."$limitStr$offsetStr",$inputarr);
return $rs;
}
@@ -261,7 +261,7 @@ class ADODB_sqlite extends ADOConnection {
return @sqlite_close($this->_connectionID);
}
function &MetaIndexes($table, $primary = FALSE, $owner=false)
function MetaIndexes($table, $primary = FALSE, $owner=false)
{
$false = false;
// save old fetch mode
@@ -350,7 +350,7 @@ class ADORecordset_sqlite extends ADORecordSet {
}
function &FetchField($fieldOffset = -1)
function FetchField($fieldOffset = -1)
{
$fld = new ADOFieldObject;
$fld->name = sqlite_field_name($this->_queryID, $fieldOffset);

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim. All rights reserved.
V5.08 6 Apr 2009 (c) 2000-2009 John Lim. 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.
@@ -123,6 +123,12 @@ class ADODB_sybase extends ADOConnection {
{
if (!function_exists('sybase_connect')) return null;
if ($this->charSet) {
$this->_connectionID = sybase_connect($argHostname,$argUsername,$argPassword, $this->charSet);
} else {
$this->_connectionID = sybase_connect($argHostname,$argUsername,$argPassword);
}
$this->_connectionID = sybase_connect($argHostname,$argUsername,$argPassword);
if ($this->_connectionID === false) return false;
if ($argDatabasename) return $this->SelectDB($argDatabasename);
@@ -133,14 +139,18 @@ class ADODB_sybase extends ADOConnection {
{
if (!function_exists('sybase_connect')) return null;
$this->_connectionID = sybase_pconnect($argHostname,$argUsername,$argPassword);
if ($this->charSet) {
$this->_connectionID = sybase_pconnect($argHostname,$argUsername,$argPassword, $this->charSet);
} else {
$this->_connectionID = sybase_pconnect($argHostname,$argUsername,$argPassword);
}
if ($this->_connectionID === false) return false;
if ($argDatabasename) return $this->SelectDB($argDatabasename);
return true;
}
// returns query ID if successful, otherwise false
function _query($sql,$inputarr)
function _query($sql,$inputarr=false)
{
global $ADODB_COUNTRECS;
@@ -151,10 +161,10 @@ class ADODB_sybase extends ADOConnection {
}
// See http://www.isug.com/Sybase_FAQ/ASE/section6.2.html#6.2.12
function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
{
if ($secs2cache > 0) {// we do not cache rowcount, so we have to load entire recordset
$rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
$rs = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
return $rs;
}
@@ -165,7 +175,7 @@ class ADODB_sybase extends ADOConnection {
if ($offset > 0 && $cnt) $cnt += $offset;
$this->Execute("set rowcount $cnt");
$rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,0);
$rs = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,0);
$this->Execute("set rowcount 0");
return $rs;
@@ -177,12 +187,12 @@ class ADODB_sybase extends ADOConnection {
return @sybase_close($this->_connectionID);
}
function UnixDate($v)
static function UnixDate($v)
{
return ADORecordSet_array_sybase::UnixDate($v);
}
function UnixTimeStamp($v)
static function UnixTimeStamp($v)
{
return ADORecordSet_array_sybase::UnixTimeStamp($v);
}
@@ -211,7 +221,7 @@ class ADODB_sybase extends ADOConnection {
$s .= "convert(char(3),$col,0)";
break;
case 'm':
$s .= "replace(str(month($col),2),' ','0')";
$s .= "str_replace(str(month($col),2),' ','0')";
break;
case 'Q':
case 'q':
@@ -219,21 +229,21 @@ class ADODB_sybase extends ADOConnection {
break;
case 'D':
case 'd':
$s .= "replace(str(datepart(dd,$col),2),' ','0')";
$s .= "str_replace(str(datepart(dd,$col),2),' ','0')";
break;
case 'h':
$s .= "substring(convert(char(14),$col,0),13,2)";
break;
case 'H':
$s .= "replace(str(datepart(hh,$col),2),' ','0')";
$s .= "str_replace(str(datepart(hh,$col),2),' ','0')";
break;
case 'i':
$s .= "replace(str(datepart(mi,$col),2),' ','0')";
$s .= "str_replace(str(datepart(mi,$col),2),' ','0')";
break;
case 's':
$s .= "replace(str(datepart(ss,$col),2),' ','0')";
$s .= "str_replace(str(datepart(ss,$col),2),' ','0')";
break;
case 'a':
case 'A':
@@ -300,7 +310,7 @@ class ADORecordset_sybase extends ADORecordSet {
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. */
function &FetchField($fieldOffset = -1)
function FetchField($fieldOffset = -1)
{
if ($fieldOffset != -1) {
$o = @sybase_fetch_field($this->_queryID, $fieldOffset);
@@ -353,12 +363,12 @@ class ADORecordset_sybase extends ADORecordSet {
}
// sybase/mssql uses a default date like Dec 30 2000 12:00AM
function UnixDate($v)
static function UnixDate($v)
{
return ADORecordSet_array_sybase::UnixDate($v);
}
function UnixTimeStamp($v)
static function UnixTimeStamp($v)
{
return ADORecordSet_array_sybase::UnixTimeStamp($v);
}
@@ -371,12 +381,12 @@ class ADORecordSet_array_sybase extends ADORecordSet_array {
}
// sybase/mssql uses a default date like Dec 30 2000 12:00AM
function UnixDate($v)
static function UnixDate($v)
{
global $ADODB_sybase_mths;
//Dec 30 2000 12:00AM
if (!ereg( "([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})"
if (!preg_match( "/([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})/"
,$v, $rr)) return parent::UnixDate($v);
if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
@@ -388,12 +398,12 @@ class ADORecordSet_array_sybase extends ADORecordSet_array {
return mktime(0,0,0,$themth,$rr[2],$rr[3]);
}
function UnixTimeStamp($v)
static function UnixTimeStamp($v)
{
global $ADODB_sybase_mths;
//11.02.2001 Toni Tunkkari toni.tunkkari@finebyte.com
//Changed [0-9] to [0-9 ] in day conversion
if (!ereg( "([A-Za-z]{3})[-/\. ]([0-9 ]{1,2})[-/\. ]([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})"
if (!preg_match( "/([A-Za-z]{3})[-/\. ]([0-9 ]{1,2})[-/\. ]([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})/"
,$v, $rr)) return parent::UnixTimeStamp($v);
if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -25,7 +25,7 @@ class ADODB_sybase_ase extends ADODB_sybase {
}
// split the Views, Tables and procedures.
function &MetaTables($ttype=false,$showSchema=false,$mask=false)
function MetaTables($ttype=false,$showSchema=false,$mask=false)
{
$false = false;
if ($this->metaTablesSQL) {
@@ -43,7 +43,7 @@ class ADODB_sybase_ase extends ADODB_sybase {
if ($rs === false || !method_exists($rs, 'GetArray')){
return $false;
}
$arr =& $rs->GetArray();
$arr = $rs->GetArray();
$arr2 = array();
foreach($arr as $key=>$value){
@@ -71,7 +71,7 @@ class ADODB_sybase_ase extends ADODB_sybase {
}
// fix a bug which prevent the metaColumns query to be executed for Sybase ASE
function &MetaColumns($table,$upper=false)
function MetaColumns($table,$upper=false)
{
$false = false;
if (!empty($this->metaColumnsSQL)) {
@@ -81,7 +81,7 @@ class ADODB_sybase_ase extends ADODB_sybase {
$retarr = array();
while (!$rs->EOF) {
$fld =& new ADOFieldObject();
$fld = new ADOFieldObject();
$fld->name = $rs->Fields('field_name');
$fld->type = $rs->Fields('type');
$fld->max_length = $rs->Fields('width');

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 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.
@@ -55,7 +55,7 @@ class ADODB_vfp extends ADODB_odbc {
// TOP requires ORDER BY for VFP
function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
{
$this->hasTop = preg_match('/ORDER[ \t\r\n]+BY/is',$sql) ? 'top' : false;
$ret = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);