MDL-20899 import latest adodb 5.10

This commit is contained in:
Petr Skoda
2009-11-18 21:18:25 +00:00
parent f2a0da6c41
commit 2d7f16e204
83 changed files with 1395 additions and 1785 deletions
+16 -5
View File
@@ -1,7 +1,7 @@
<?php
/*
@version V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
@version V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Latest version is available at http://adodb.sourceforge.net
Released under both BSD license and Lesser GPL library license.
@@ -26,6 +26,7 @@ global $ADODB_ACTIVE_DEFVALS; // use default values of table definition when cre
$_ADODB_ACTIVE_DBS = array();
$ACTIVE_RECORD_SAFETY = true;
$ADODB_ACTIVE_DEFVALS = false;
$ADODB_ACTIVE_CACHESECS = 0;
class ADODB_Active_DB {
var $db; // ADOConnection
@@ -73,6 +74,8 @@ function ADODB_SetDatabaseAdapter(&$db, $index=false)
class ADODB_Active_Record {
static $_changeNames = true; // dynamically pluralize table names
static $_quoteNames = false;
static $_foreignSuffix = '_id'; //
var $_dbat; // associative index pointing to ADODB_Active_DB eg. $ADODB_Active_DBS[_dbat]
var $_table; // tablename, if set in class definition then use it as table name
@@ -655,6 +658,13 @@ class ADODB_Active_Record {
}
function _QName($n,$db=false)
{
if (!ADODB_Active_Record::$_quoteNames) return $n;
if (!$db) $db = $this->DB(); if (!$db) return false;
return $db->nameQuote.$n.$db->nameQuote;
}
//------------------------------------------------------------ Public functions below
function Load($where=null,$bindarr=false)
@@ -708,6 +718,7 @@ class ADODB_Active_Record {
return $ok;
}
// false on error
function Insert()
{
@@ -723,7 +734,7 @@ class ADODB_Active_Record {
$val = $this->$name;
if(!is_array($val) || !is_null($val) || !array_key_exists($name, $table->keys)) {
$valarr[] = $val;
$names[] = $name;
$names[] = $this->_QName($name,$db);
$valstr[] = $db->Param($cnt);
$cnt += 1;
}
@@ -883,7 +894,7 @@ class ADODB_Active_Record {
continue;
}
$valarr[] = $val;
$pairs[] = $name.'='.$db->Param($cnt);
$pairs[] = $this->_QName($name,$db).'='.$db->Param($cnt);
$cnt += 1;
}
@@ -922,9 +933,9 @@ global $_ADODB_ACTIVE_DBS;
{
$rows = false;
if(isset($extra['offset'])) {
$rs = $db->SelectLimit($qry, $extra['limit'], $extra['offset']);
$rs = $db->SelectLimit($qry, $extra['limit'], $extra['offset'],$bindarr);
} else {
$rs = $db->SelectLimit($qry, $extra['limit']);
$rs = $db->SelectLimit($qry, $extra['limit'],-1,$bindarr);
}
if ($rs) {
while (!$rs->EOF) {
+2 -1
View File
@@ -8,7 +8,7 @@ $ADODB_INCLUDED_CSV = 1;
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
@@ -71,6 +71,7 @@ $ADODB_INCLUDED_CSV = 1;
$savefetch = isset($rs->adodbFetchMode) ? $rs->adodbFetchMode : $rs->fetchMode;
$class = $rs->connection->arrayClass;
$rs2 = new $class();
$rs2->timeCreated = $rs->timeCreated; # memcache fix
$rs2->sql = $rs->sql;
$rs2->oldProvider = $rs->dataProvider;
$rs2->InitArrayFields($rows,$flds);
+2 -2
View File
@@ -1,7 +1,7 @@
<?php
/**
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -519,7 +519,7 @@ class ADODB_DataDict {
// genfields can return FALSE at times
if ($lines == null) $lines = array();
list(,$first) = each($lines);
list(,$column_def) = split("[\t ]+",$first,2);
list(,$column_def) = preg_split("/[\t ]+/",$first,2);
}
return array(sprintf($this->renameColumn,$tabname,$this->NameQuote($oldcolumn),$this->NameQuote($newcolumn),$column_def));
}
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
/**
* @version V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
* @version V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
/**
* @version V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
* @version V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+9 -11
View File
@@ -1001,13 +1001,11 @@ function _adodb_column_sql(&$zthis, $action, $type, $fname, $fnameq, $arrFields,
$val = $zthis->DBTimeStamp($arrFields[$fname]);
break;
case "F": //Floating point number // Moodle added
case "N":
$val = $arrFields[$fname];
if (!is_numeric($val)) $val = str_replace(',', '.', (float)$val);
break;
case "L": //Integer field suitable for storing booleans (0 or 1) // Moodle added
case "I":
case "R":
$val = $arrFields[$fname];
@@ -1055,13 +1053,13 @@ function _adodb_debug_execute(&$zthis, $sql, $inputarr)
$ss = '<code>'.htmlspecialchars($ss).'</code>';
}
if ($zthis->debug === -1)
ADOConnection::outp( "<br />\n($dbt): ".htmlspecialchars($sqlTxt)." &nbsp; $ss\n<br />\n",false); /// Moodle XHTML
ADOConnection::outp( "<br>\n($dbt): ".htmlspecialchars($sqlTxt)." &nbsp; $ss\n<br>\n",false);
else if ($zthis->debug !== -99)
ADOConnection::outp( "<hr />\n($dbt): ".htmlspecialchars($sqlTxt)." &nbsp; $ss\n<hr />\n",false); /// Moodle XHTML
ADOConnection::outp( "<hr>\n($dbt): ".htmlspecialchars($sqlTxt)." &nbsp; $ss\n<hr>\n",false);
} else {
$ss = "\n ".$ss;
if ($zthis->debug !== -99)
ADOConnection::outp("-----<hr />\n($dbt): ".$sqlTxt." $ss\n-----<hr />\n",false); /// Moodle XHTML
ADOConnection::outp("-----<hr>\n($dbt): ".$sqlTxt." $ss\n-----<hr>\n",false);
}
$qID = $zthis->_query($sql,$inputarr);
@@ -1076,7 +1074,7 @@ function _adodb_debug_execute(&$zthis, $sql, $inputarr)
if($emsg = $zthis->ErrorMsg()) {
if ($err = $zthis->ErrorNo()) {
if ($zthis->debug === -99)
ADOConnection::outp( "<hr />\n($dbt): ".htmlspecialchars($sqlTxt)." &nbsp; $ss\n<hr />\n",false); /// Moodle XHTML
ADOConnection::outp( "<hr>\n($dbt): ".htmlspecialchars($sqlTxt)." &nbsp; $ss\n<hr>\n",false);
ADOConnection::outp($err.': '.$emsg);
}
@@ -1084,8 +1082,8 @@ function _adodb_debug_execute(&$zthis, $sql, $inputarr)
} else if (!$qID) {
if ($zthis->debug === -99)
if ($inBrowser) ADOConnection::outp( "<hr />\n($dbt): ".htmlspecialchars($sqlTxt)." &nbsp; $ss\n<hr />\n",false); /// Moodle XHTML
else ADOConnection::outp("-----<hr />\n($dbt): ".$sqlTxt."$ss\n-----<hr />\n",false);
if ($inBrowser) ADOConnection::outp( "<hr>\n($dbt): ".htmlspecialchars($sqlTxt)." &nbsp; $ss\n<hr>\n",false);
else ADOConnection::outp("-----<hr>\n($dbt): ".$sqlTxt."$ss\n-----<hr>\n",false);
ADOConnection::outp($zthis->ErrorNo() .': '. $zthis->ErrorMsg());
}
@@ -1102,11 +1100,11 @@ function _adodb_backtrace($printOrArr=true,$levels=9999,$skippy=0,$ishtml=null)
if ($ishtml === null) $html = (isset($_SERVER['HTTP_USER_AGENT']));
else $html = $ishtml;
$fmt = ($html) ? "</font><font color=\"#808080\" size=\"-1\"> %% line %4d, file: <a href=\"file:/%s\">%s</a></font>" : "%% line %4d, file: %s"; /// Moodle XHTML
$fmt = ($html) ? "</font><font color=#808080 size=-1> %% line %4d, file: <a href=\"file:/%s\">%s</a></font>" : "%% line %4d, file: %s";
$MAXSTRLEN = 128;
$s = ($html) ? '<pre align="left">' : ''; /// Moodle XHTML
$s = ($html) ? '<pre align=left>' : '';
if (is_array($printOrArr)) $traceArr = $printOrArr;
else $traceArr = debug_backtrace();
@@ -1192,4 +1190,4 @@ function _adodb_find_from($sql)
}
*/
?>
?>
+1 -1
View File
@@ -65,7 +65,7 @@ $db->CacheExecute($sql);
$memcache = new MemCache;
if (!is_array($this->hosts)) $this->hosts = array($hosts);
if (!is_array($this->hosts)) $this->hosts = array($this->hosts);
$failcnt = 0;
foreach($this->hosts as $host) {
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+3 -5
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
@@ -57,12 +57,10 @@ function adodb_round($n,$prec)
return number_format($n, $prec, '.', '');
}
/* return microtime value as a float */
/* obsolete: return microtime value as a float. Retained for backward compat */
function adodb_microtime()
{
$t = microtime();
$t = explode(' ',$t);
return (float)$t[1]+ (float)$t[0];
return microtime(true);
}
/* sql code timing */
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+1 -1
View File
@@ -1214,7 +1214,7 @@ function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=fa
// for windows, we don't check 1970 because with timezone differences,
// 1 Jan 1970 could generate negative timestamp, which is illegal
$usephpfns = (1971 < $year && $year < 2038
$usephpfns = (1970 < $year && $year < 2038
|| !defined('ADODB_NO_NEGATIVE_TS') && (1901 < $year && $year < 2038)
);
+25 -13
View File
@@ -14,7 +14,7 @@
/**
\mainpage
@version V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
@version V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license. You can choose which license
you prefer.
@@ -177,7 +177,7 @@
/**
* ADODB version as a string.
*/
$ADODB_vers = 'V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. Released BSD & LGPL.';
$ADODB_vers = 'V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. Released BSD & LGPL.';
/**
* Determines whether recordset->RecordCount() is used.
@@ -377,6 +377,7 @@
var $sysDate = false; /// name of function that returns the current date
var $sysTimeStamp = false; /// name of function that returns the current timestamp
var $sysUTimeStamp = false; // name of function that returns the current timestamp accurate to the microsecond or nearest fraction
var $arrayClass = 'ADORecordSet_array'; /// name of class used to generate array recordsets, which are pre-downloaded recordsets
var $noNullStrings = false; /// oracle specific stuff - if true ensures that '' is converted to ' '
@@ -515,9 +516,6 @@
$this->_isPersistentConnection = false;
global $ADODB_CACHE;
if (empty($ADODB_CACHE)) $this->_CreateCache();
if ($forceNew) {
if ($rez=$this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true;
} else {
@@ -584,9 +582,6 @@
$this->_isPersistentConnection = true;
global $ADODB_CACHE;
if (empty($ADODB_CACHE)) $this->_CreateCache();
if ($rez = $this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true;
if (isset($rez)) {
$err = $this->ErrorMsg();
@@ -721,7 +716,7 @@
* @param $table name of table to lock
* @param $where where clause to use, eg: "WHERE row=12". If left empty, will escalate to table lock
*/
function RowLock($table,$where)
function RowLock($table,$where,$col='1 as ignore')
{
return false;
}
@@ -1710,6 +1705,8 @@
{
global $ADODB_CACHE_DIR, $ADODB_CACHE;
if (empty($ADODB_CACHE)) return false;
if (!$sql) {
$ADODB_CACHE->flushall($this->debug);
return;
@@ -1766,6 +1763,8 @@
{
global $ADODB_CACHE;
if (empty($ADODB_CACHE)) $this->_CreateCache();
if (!is_numeric($secs2cache)) {
$inputarr = $sql;
$sql = $secs2cache;
@@ -1878,6 +1877,7 @@
$rs = $this->SelectLimit($sql,1);
if (!$rs) return $false; // table does not exist
$rs->tableName = $table;
$rs->sql = $sql;
switch((string) $mode) {
case 'UPDATE':
@@ -2439,6 +2439,9 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
if (empty($d) && $d !== 0) return 'null';
if ($isfld) return $d;
if (is_object($d)) return $d->format($this->fmtDate);
if (is_string($d) && !is_numeric($d)) {
if ($d === 'null' || strncmp($d,"'",1) === 0) return $d;
if ($this->isoDates) return "'$d'";
@@ -2476,6 +2479,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
{
if (empty($ts) && $ts !== 0) return 'null';
if ($isfld) return $ts;
if (is_object($ts)) return $ts->format($this->fmtTimeStamp);
# strlen(14) allows YYYYMMDDHHMMSS format
if (!is_string($ts) || (is_numeric($ts) && strlen($ts)<14))
@@ -2604,9 +2608,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
// undo magic quotes for "
$s = str_replace('\\"','"',$s);
// moodle change start - see readme_moodle.txt
if ($this->replaceQuote == "\\'" || ini_get('magic_quotes_sybase')) // ' already quoted, no need to change anything
// moodle change end - see readme_moodle.txt
return $s;
else {// change \' to '' for sybase/mssql
$s = str_replace('\\\\','\\',$s);
@@ -2640,9 +2642,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
// undo magic quotes for "
$s = str_replace('\\"','"',$s);
// moodle change start - see readme_moodle.txt
if ($this->replaceQuote == "\\'" || ini_get('magic_quotes_sybase')) // ' already quoted, no need to change anything
// moodle change end - see readme_moodle.txt
return "'$s'";
else {// change \' to '' for sybase/mssql
$s = str_replace('\\\\','\\',$s);
@@ -4258,6 +4258,18 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
case 'socket': $obj->socket = $v; break;
#oci8
case 'nls_date_format': $obj->NLS_DATE_FORMAT = $v; break;
case 'cachesecs': $obj->cacheSecs = $v; break;
case 'memcache':
$varr = explode(':',$v);
$vlen = sizeof($varr);
if ($vlen == 0) break;
$obj->memCache = true;
$obj->memCacheHost = explode(',',$varr[0]);
if ($vlen == 1) break;
$obj->memCachePort = $varr[1];
if ($vlen == 2) break;
$obj->memCacheCompress = $varr[2] ? true : false;
break;
}
}
if (empty($persist))
+3 -2
View File
@@ -1,7 +1,7 @@
<?php
/**
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -30,7 +30,8 @@ class ADODB2_access extends ADODB_DataDict {
case 'X2': return 'MEMO';
case 'B': return 'BINARY';
case 'TS':
case 'D': return 'DATETIME';
case 'T': return 'DATETIME';
+2 -1
View File
@@ -1,7 +1,7 @@
<?php
/**
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -30,6 +30,7 @@ class ADODB2_db2 extends ADODB_DataDict {
case 'B': return 'BLOB';
case 'D': return 'DATE';
case 'TS':
case 'T': return 'TIMESTAMP';
case 'L': return 'SMALLINT';
+2 -1
View File
@@ -1,7 +1,7 @@
<?php
/**
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -30,6 +30,7 @@ class ADODB2_firebird extends ADODB_DataDict {
case 'B': return 'BLOB';
case 'D': return 'DATE';
case 'TS':
case 'T': return 'TIMESTAMP';
case 'L': return 'SMALLINT';
+2 -1
View File
@@ -1,7 +1,7 @@
<?php
/**
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -32,6 +32,7 @@ class ADODB2_generic extends ADODB_DataDict {
case 'B': return 'VARCHAR';
case 'D': return 'DATE';
case 'TS':
case 'T': return 'DATE';
case 'L': return 'DECIMAL(1)';
+2 -1
View File
@@ -1,7 +1,7 @@
<?php
/**
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -32,6 +32,7 @@ class ADODB2_ibase extends ADODB_DataDict {
case 'B': return 'BLOB';
case 'D': return 'DATE';
case 'TS':
case 'T': return 'TIMESTAMP';
case 'L': return 'SMALLINT';
+2 -1
View File
@@ -1,7 +1,7 @@
<?php
/**
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -32,6 +32,7 @@ class ADODB2_informix extends ADODB_DataDict {
case 'B': return 'BLOB';
case 'D': return 'DATE';
case 'TS':
case 'T': return 'DATETIME YEAR TO SECOND';
case 'L': return 'SMALLINT';
+3 -1
View File
@@ -1,7 +1,7 @@
<?php
/**
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -89,6 +89,8 @@ class ADODB2_mssql extends ADODB_DataDict {
case 'B': return 'IMAGE';
case 'D': return 'DATETIME';
case 'TS':
case 'T': return 'DATETIME';
case 'L': return 'BIT';
@@ -1,7 +1,7 @@
<?php
/**
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+2 -1
View File
@@ -1,7 +1,7 @@
<?php
/**
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -89,6 +89,7 @@ class ADODB2_mysql extends ADODB_DataDict {
case 'B': return 'LONGBLOB';
case 'D': return 'DATE';
case 'TS':
case 'T': return 'DATETIME';
case 'L': return 'TINYINT';
+8 -2
View File
@@ -1,7 +1,7 @@
<?php
/**
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -55,6 +55,9 @@ class ADODB2_oci8 extends ADODB_DataDict {
case 'BLOB':
return 'B';
case 'TIMESTAMP':
return 'TS';
case 'DATE':
return 'T';
@@ -79,7 +82,10 @@ class ADODB2_oci8 extends ADODB_DataDict {
case 'X2': return 'NVARCHAR2(4000)';
case 'B': return 'BLOB';
case 'TS':
return 'TIMESTAMP';
case 'D':
case 'T': return 'DATE';
case 'L': return 'NUMBER(1)';
+2 -1
View File
@@ -1,7 +1,7 @@
<?php
/**
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -100,6 +100,7 @@ class ADODB2_postgres extends ADODB_DataDict {
case 'B': return 'BYTEA';
case 'D': return 'DATE';
case 'TS':
case 'T': return 'TIMESTAMP';
case 'L': return 'BOOLEAN';
@@ -33,6 +33,7 @@ class ADODB2_sapdb extends ADODB_DataDict {
case 'B': return 'LONG';
case 'D': return 'DATE';
case 'TS':
case 'T': return 'TIMESTAMP';
case 'L': return 'BOOLEAN';
+2 -1
View File
@@ -1,7 +1,7 @@
<?php
/**
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -55,6 +55,7 @@ class ADODB2_sybase extends ADODB_DataDict {
case 'B': return 'IMAGE';
case 'D': return 'DATETIME';
case 'TS':
case 'T': return 'DATETIME';
case 'L': return 'BIT';
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -169,7 +169,7 @@ class ADODB_ado extends ADOConnection {
return $arr;
}
function MetaColumns($table)
function MetaColumns($table, $normalize=true)
{
$table = strtoupper($table);
$arr = array();
+6 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -194,7 +194,7 @@ class ADODB_ado extends ADOConnection {
return $arr;
}
function MetaColumns($table)
function MetaColumns($table, $normalize=true)
{
$table = strtoupper($table);
$arr= array();
@@ -640,6 +640,10 @@ class ADORecordSet_ado extends ADORecordSet {
case 1: // null
$this->fields[] = false;
break;
case 20:
case 21: // bigint (64 bit)
$this->fields[] = (float) $f->value; // if 64 bit PHP, could use (int)
break;
case 6: // currency is not supported properly;
ADOConnection::outp( '<b>'.$f->Name.': currency type not supported by PHP</b>');
$this->fields[] = (float) $f->value;
+3 -4
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
@@ -26,7 +26,6 @@ class ADODB_ado_access extends ADODB_ado {
var $fmtTimeStamp = "#Y-m-d h:i:sA#";// note no comma
var $sysDate = "FORMAT(NOW,'yyyy-mm-dd')";
var $sysTimeStamp = 'NOW';
var $hasTransactions = false;
var $upperCase = 'ucase';
function ADODB_ado_access()
@@ -34,11 +33,11 @@ class ADODB_ado_access extends ADODB_ado {
$this->ADODB_ado();
}
function BeginTrans() { return false;}
/*function BeginTrans() { return false;}
function CommitTrans() { return false;}
function RollbackTrans() { return false;}
function RollbackTrans() { return false;}*/
}
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -71,7 +71,7 @@ class ADODB_ado_mssql extends ADODB_ado {
return str_replace("\0", "\\\\000", $s);
}
function MetaColumns($table)
function MetaColumns($table, $normalize=true)
{
$table = strtoupper($table);
$arr= array();
+796
View File
@@ -0,0 +1,796 @@
<?php
/*
(c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
Portions Copyright (c) 2007-2009, iAnywhere Solutions, Inc.
All rights reserved. All unpublished 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.
NOTE: This driver requires the Advantage PHP client libraries, which
can be downloaded for free via:
http://devzone.advantagedatabase.com/dz/content.aspx?key=20
DELPHI FOR PHP USERS:
The following steps can be taken to utilize this driver from the
CodeGear Delphi for PHP product:
1 - See note above, download and install the Advantage PHP client.
2 - Copy the following files to the Delphi for PHP\X.X\php\ext directory:
ace32.dll
axcws32.dll
adsloc32.dll
php_advantage.dll (rename the existing php_advantage.dll.5.x.x file)
3 - Add the following line to the Delphi for PHP\X.X\php\php.ini.template file:
extension=php_advantage.dll
4 - To use: enter "ads" as the DriverName on a connection component, and set
a Host property similar to "DataDirectory=c:\". See the Advantage PHP
help file topic for ads_connect for details on connection path options
and formatting.
5 - (optional) - Modify the Delphi for PHP\X.X\vcl\packages\database.packages.php
file and add ads to the list of strings returned when registering the
Database object's DriverName property.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
define("_ADODB_ADS_LAYER", 2 );
/*--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------*/
class ADODB_ads extends ADOConnection {
var $databaseType = "ads";
var $fmt = "'m-d-Y'";
var $fmtTimeStamp = "'Y-m-d H:i:s'";
var $concat_operator = '';
var $replaceQuote = "''"; // string to use to replace quotes
var $dataProvider = "ads";
var $hasAffectedRows = true;
var $binmode = ODBC_BINMODE_RETURN;
var $useFetchArray = false; // setting this to true will make array elements in FETCH_ASSOC mode case-sensitive
// breaking backward-compat
//var $longreadlen = 8000; // default number of chars to return for a Blob/Long field
var $_bindInputArray = false;
var $curmode = SQL_CUR_USE_DRIVER; // See sqlext.h, SQL_CUR_DEFAULT == SQL_CUR_USE_DRIVER == 2L
var $_genSeqSQL = "create table %s (id integer)";
var $_autocommit = true;
var $_haserrorfunctions = true;
var $_has_stupid_odbc_fetch_api_change = true;
var $_lastAffectedRows = 0;
var $uCaseTables = true; // for meta* functions, uppercase table names
function ADODB_ads()
{
$this->_haserrorfunctions = ADODB_PHPVER >= 0x4050;
$this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200;
}
// returns true or false
function _connect($argDSN, $argUsername, $argPassword, $argDatabasename)
{
global $php_errormsg;
if (!function_exists('ads_connect')) return null;
if ($this->debug && $argDatabasename && $this->databaseType != 'vfp') {
ADOConnection::outp("For Advantage Connect(), $argDatabasename is not used. Place dsn in 1st parameter.");
}
if (isset($php_errormsg)) $php_errormsg = '';
if ($this->curmode === false) $this->_connectionID = ads_connect($argDSN,$argUsername,$argPassword);
else $this->_connectionID = ads_connect($argDSN,$argUsername,$argPassword,$this->curmode);
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
if (isset($this->connectStmt)) $this->Execute($this->connectStmt);
return $this->_connectionID != false;
}
// returns true or false
function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
{
global $php_errormsg;
if (!function_exists('ads_connect')) return null;
if (isset($php_errormsg)) $php_errormsg = '';
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
if ($this->debug && $argDatabasename) {
ADOConnection::outp("For PConnect(), $argDatabasename is not used. Place dsn in 1st parameter.");
}
// print "dsn=$argDSN u=$argUsername p=$argPassword<br>"; flush();
if ($this->curmode === false) $this->_connectionID = ads_connect($argDSN,$argUsername,$argPassword);
else $this->_connectionID = ads_pconnect($argDSN,$argUsername,$argPassword,$this->curmode);
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
if ($this->_connectionID && $this->autoRollback) @ads_rollback($this->_connectionID);
if (isset($this->connectStmt)) $this->Execute($this->connectStmt);
return $this->_connectionID != false;
}
// returns the Server version and Description
function ServerInfo()
{
if (!empty($this->host) && ADODB_PHPVER >= 0x4300) {
$stmt = $this->Prepare('EXECUTE PROCEDURE sp_mgGetInstallInfo()');
$res = $this->Execute($stmt);
if(!$res)
print $this->ErrorMsg();
else{
$ret["version"]= $res->fields[3];
$ret["description"]="Advantage Database Server";
return $ret;
}
}
else {
return ADOConnection::ServerInfo();
}
}
// returns true or false
function CreateSequence( $seqname,$start=1)
{
$res = $this->Execute("CREATE TABLE $seqname ( ID autoinc( 1 ) ) IN DATABASE");
if(!$res){
print $this->ErrorMsg();
return false;
}
else
return true;
}
// returns true or false
function DropSequence($seqname)
{
$res = $this->Execute("DROP TABLE $seqname");
if(!$res){
print $this->ErrorMsg();
return false;
}
else
return true;
}
// returns the generated ID or false
// checks if the table already exists, else creates the table and inserts a record into the table
// and gets the ID number of the last inserted record.
function GenID($seqname,$start=1)
{
$go = $this->Execute("select * from $seqname");
if (!$go){
$res = $this->Execute("CREATE TABLE $seqname ( ID autoinc( 1 ) ) IN DATABASE");
if(!res){
print $this->ErrorMsg();
return false;
}
}
$res = $this->Execute("INSERT INTO $seqname VALUES( DEFAULT )");
if(!$res){
print $this->ErrorMsg();
return false;
}
else{
$gen = $this->Execute("SELECT LastAutoInc( STATEMENT ) FROM system.iota");
$ret = $gen->fields[0];
return $ret;
}
}
function ErrorMsg()
{
if ($this->_haserrorfunctions) {
if ($this->_errorMsg !== false) return $this->_errorMsg;
if (empty($this->_connectionID)) return @ads_errormsg();
return @ads_errormsg($this->_connectionID);
} else return ADOConnection::ErrorMsg();
}
function ErrorNo()
{
if ($this->_haserrorfunctions) {
if ($this->_errorCode !== false) {
// bug in 4.0.6, error number can be corrupted string (should be 6 digits)
return (strlen($this->_errorCode)<=2) ? 0 : $this->_errorCode;
}
if (empty($this->_connectionID)) $e = @ads_error();
else $e = @ads_error($this->_connectionID);
// bug in 4.0.6, error number can be corrupted string (should be 6 digits)
// so we check and patch
if (strlen($e)<=2) return 0;
return $e;
} else return ADOConnection::ErrorNo();
}
function BeginTrans()
{
if (!$this->hasTransactions) return false;
if ($this->transOff) return true;
$this->transCnt += 1;
$this->_autocommit = false;
return ads_autocommit($this->_connectionID,false);
}
function CommitTrans($ok=true)
{
if ($this->transOff) return true;
if (!$ok) return $this->RollbackTrans();
if ($this->transCnt) $this->transCnt -= 1;
$this->_autocommit = true;
$ret = ads_commit($this->_connectionID);
ads_autocommit($this->_connectionID,true);
return $ret;
}
function RollbackTrans()
{
if ($this->transOff) return true;
if ($this->transCnt) $this->transCnt -= 1;
$this->_autocommit = true;
$ret = ads_rollback($this->_connectionID);
ads_autocommit($this->_connectionID,true);
return $ret;
}
// Returns tables,Views or both on succesfull execution. Returns
// tables by default on succesfull execustion.
function &MetaTables($ttype)
{
$recordSet1 = $this->Execute("select * from system.tables");
if(!$recordSet1){
print $this->ErrorMsg();
return false;
}
$recordSet2 = $this->Execute("select * from system.views");
if(!$recordSet2){
print $this->ErrorMsg();
return false;
}
$i=0;
while (!$recordSet1->EOF){
$arr["$i"] = $recordSet1->fields[0];
$recordSet1->MoveNext();
$i=$i+1;
}
if($ttype=='FALSE'){
while (!$recordSet2->EOF){
$arr["$i"] = $recordSet2->fields[0];
$recordSet2->MoveNext();
$i=$i+1;
}
return $arr;
}
elseif($ttype=='VIEWS'){
while (!$recordSet2->EOF){
$arrV["$i"] = $recordSet2->fields[0];
$recordSet2->MoveNext();
$i=$i+1;
}
return $arrV;
}
else{
return $arr;
}
}
function &MetaPrimaryKeys($table)
{
$recordSet = $this->Execute("select table_primary_key from system.tables where name='$table'");
if(!$recordSet){
print $this->ErrorMsg();
return false;
}
$i=0;
while (!$recordSet->EOF){
$arr["$i"] = $recordSet->fields[0];
$recordSet->MoveNext();
$i=$i+1;
}
return $arr;
}
/*
See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcdatetime_data_type_changes.asp
/ SQL data type codes /
#define SQL_UNKNOWN_TYPE 0
#define SQL_CHAR 1
#define SQL_NUMERIC 2
#define SQL_DECIMAL 3
#define SQL_INTEGER 4
#define SQL_SMALLINT 5
#define SQL_FLOAT 6
#define SQL_REAL 7
#define SQL_DOUBLE 8
#if (ODBCVER >= 0x0300)
#define SQL_DATETIME 9
#endif
#define SQL_VARCHAR 12
/ One-parameter shortcuts for date/time data types /
#if (ODBCVER >= 0x0300)
#define SQL_TYPE_DATE 91
#define SQL_TYPE_TIME 92
#define SQL_TYPE_TIMESTAMP 93
#define SQL_UNICODE (-95)
#define SQL_UNICODE_VARCHAR (-96)
#define SQL_UNICODE_LONGVARCHAR (-97)
*/
function ODBCTypes($t)
{
switch ((integer)$t) {
case 1:
case 12:
case 0:
case -95:
case -96:
return 'C';
case -97:
case -1: //text
return 'X';
case -4: //image
return 'B';
case 9:
case 91:
return 'D';
case 10:
case 11:
case 92:
case 93:
return 'T';
case 4:
case 5:
case -6:
return 'I';
case -11: // uniqidentifier
return 'R';
case -7: //bit
return 'L';
default:
return 'N';
}
}
function &MetaColumns($table)
{
global $ADODB_FETCH_MODE;
$false = false;
if ($this->uCaseTables) $table = strtoupper($table);
$schema = '';
$this->_findschema($table,$schema);
$savem = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
/*if (false) { // after testing, confirmed that the following does not work becoz of a bug
$qid2 = ads_tables($this->_connectionID);
$rs = new ADORecordSet_ads($qid2);
$ADODB_FETCH_MODE = $savem;
if (!$rs) return false;
$rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
$rs->_fetch();
while (!$rs->EOF) {
if ($table == strtoupper($rs->fields[2])) {
$q = $rs->fields[0];
$o = $rs->fields[1];
break;
}
$rs->MoveNext();
}
$rs->Close();
$qid = ads_columns($this->_connectionID,$q,$o,strtoupper($table),'%');
} */
switch ($this->databaseType) {
case 'access':
case 'vfp':
$qid = ads_columns($this->_connectionID);#,'%','',strtoupper($table),'%');
break;
case 'db2':
$colname = "%";
$qid = ads_columns($this->_connectionID, "", $schema, $table, $colname);
break;
default:
$qid = @ads_columns($this->_connectionID,'%','%',strtoupper($table),'%');
if (empty($qid)) $qid = ads_columns($this->_connectionID);
break;
}
if (empty($qid)) return $false;
$rs = new ADORecordSet_ads($qid);
$ADODB_FETCH_MODE = $savem;
if (!$rs) return $false;
$rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
$rs->_fetch();
$retarr = array();
/*
$rs->fields indices
0 TABLE_QUALIFIER
1 TABLE_SCHEM
2 TABLE_NAME
3 COLUMN_NAME
4 DATA_TYPE
5 TYPE_NAME
6 PRECISION
7 LENGTH
8 SCALE
9 RADIX
10 NULLABLE
11 REMARKS
*/
while (!$rs->EOF) {
// adodb_pr($rs->fields);
if (strtoupper(trim($rs->fields[2])) == $table && (!$schema || strtoupper($rs->fields[1]) == $schema)) {
$fld = new ADOFieldObject();
$fld->name = $rs->fields[3];
$fld->type = $this->ODBCTypes($rs->fields[4]);
// ref: http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/dnaraccgen/html/msdn_odk.asp
// access uses precision to store length for char/varchar
if ($fld->type == 'C' or $fld->type == 'X') {
if ($this->databaseType == 'access')
$fld->max_length = $rs->fields[6];
else if ($rs->fields[4] <= -95) // UNICODE
$fld->max_length = $rs->fields[7]/2;
else
$fld->max_length = $rs->fields[7];
} else
$fld->max_length = $rs->fields[7];
$fld->not_null = !empty($rs->fields[10]);
$fld->scale = $rs->fields[8];
$retarr[strtoupper($fld->name)] = $fld;
} else if (sizeof($retarr)>0)
break;
$rs->MoveNext();
}
$rs->Close(); //-- crashes 4.03pl1 -- why?
if (empty($retarr)) $retarr = false;
return $retarr;
}
// Returns an array of columns names for a given table
function &MetaColumnNames($table)
{
$recordSet = $this->Execute("select name from system.columns where parent='$table'");
if(!$recordSet){
print $this->ErrorMsg();
return false;
}
else{
$i=0;
while (!$recordSet->EOF){
$arr["FIELD$i"] = $recordSet->fields[0];
$recordSet->MoveNext();
$i=$i+1;
}
return $arr;
}
}
function Prepare($sql)
{
if (! $this->_bindInputArray) return $sql; // no binding
$stmt = ads_prepare($this->_connectionID,$sql);
if (!$stmt) {
// we don't know whether odbc driver is parsing prepared stmts, so just return sql
return $sql;
}
return array($sql,$stmt,false);
}
/* returns queryID or false */
function _query($sql,$inputarr=false)
{
GLOBAL $php_errormsg;
if (isset($php_errormsg)) $php_errormsg = '';
$this->_error = '';
if ($inputarr) {
if (is_array($sql)) {
$stmtid = $sql[1];
} else {
$stmtid = ads_prepare($this->_connectionID,$sql);
if ($stmtid == false) {
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
return false;
}
}
if (! ads_execute($stmtid,$inputarr)) {
//@ads_free_result($stmtid);
if ($this->_haserrorfunctions) {
$this->_errorMsg = ads_errormsg();
$this->_errorCode = ads_error();
}
return false;
}
} else if (is_array($sql)) {
$stmtid = $sql[1];
if (!ads_execute($stmtid)) {
//@ads_free_result($stmtid);
if ($this->_haserrorfunctions) {
$this->_errorMsg = ads_errormsg();
$this->_errorCode = ads_error();
}
return false;
}
} else
{
$stmtid = ads_exec($this->_connectionID,$sql);
}
$this->_lastAffectedRows = 0;
if ($stmtid)
{
if (@ads_num_fields($stmtid) == 0) {
$this->_lastAffectedRows = ads_num_rows($stmtid);
$stmtid = true;
} else {
$this->_lastAffectedRows = 0;
ads_binmode($stmtid,$this->binmode);
ads_longreadlen($stmtid,$this->maxblobsize);
}
if ($this->_haserrorfunctions)
{
$this->_errorMsg = '';
$this->_errorCode = 0;
}
else
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
}
else
{
if ($this->_haserrorfunctions) {
$this->_errorMsg = ads_errormsg();
$this->_errorCode = ads_error();
} else
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
}
return $stmtid;
}
/*
Insert a null into the blob field of the table first.
Then use UpdateBlob to store the blob.
Usage:
$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
$conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
*/
function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
{
$sql = "UPDATE $table SET $column=? WHERE $where";
$stmtid = ads_prepare($this->_connectionID,$sql);
if ($stmtid == false){
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
return false;
}
if (! ads_execute($stmtid,array($val),array(SQL_BINARY) )){
if ($this->_haserrorfunctions){
$this->_errorMsg = ads_errormsg();
$this->_errorCode = ads_error();
}
return false;
}
return TRUE;
}
// returns true or false
function _close()
{
$ret = @ads_close($this->_connectionID);
$this->_connectionID = false;
return $ret;
}
function _affectedrows()
{
return $this->_lastAffectedRows;
}
}
/*--------------------------------------------------------------------------------------
Class Name: Recordset
--------------------------------------------------------------------------------------*/
class ADORecordSet_ads extends ADORecordSet {
var $bind = false;
var $databaseType = "ads";
var $dataProvider = "ads";
var $useFetchArray;
var $_has_stupid_odbc_fetch_api_change;
function ADORecordSet_ads($id,$mode=false)
{
if ($mode === false) {
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
}
$this->fetchMode = $mode;
$this->_queryID = $id;
// the following is required for mysql odbc driver in 4.3.1 -- why?
$this->EOF = false;
$this->_currentRow = -1;
//$this->ADORecordSet($id);
}
// returns the field object
function &FetchField($fieldOffset = -1)
{
$off=$fieldOffset+1; // offsets begin at 1
$o= new ADOFieldObject();
$o->name = @ads_field_name($this->_queryID,$off);
$o->type = @ads_field_type($this->_queryID,$off);
$o->max_length = @ads_field_len($this->_queryID,$off);
if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name);
else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name);
return $o;
}
/* Use associative array to get fields array */
function Fields($colname)
{
if ($this->fetchMode & ADODB_FETCH_ASSOC) 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)]];
}
function _initrs()
{
global $ADODB_COUNTRECS;
$this->_numOfRows = ($ADODB_COUNTRECS) ? @ads_num_rows($this->_queryID) : -1;
$this->_numOfFields = @ads_num_fields($this->_queryID);
// some silly drivers such as db2 as/400 and intersystems cache return _numOfRows = 0
if ($this->_numOfRows == 0) $this->_numOfRows = -1;
//$this->useFetchArray = $this->connection->useFetchArray;
$this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200;
}
function _seek($row)
{
return false;
}
// speed up SelectLimit() by switching to ADODB_FETCH_NUM as ADODB_FETCH_ASSOC is emulated
function &GetArrayLimit($nrows,$offset=-1)
{
if ($offset <= 0) {
$rs =& $this->GetArray($nrows);
return $rs;
}
$savem = $this->fetchMode;
$this->fetchMode = ADODB_FETCH_NUM;
$this->Move($offset);
$this->fetchMode = $savem;
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
}
$results = array();
$cnt = 0;
while (!$this->EOF && $nrows != $cnt) {
$results[$cnt++] = $this->fields;
$this->MoveNext();
}
return $results;
}
function MoveNext()
{
if ($this->_numOfRows != 0 && !$this->EOF) {
$this->_currentRow++;
if ($this->_has_stupid_odbc_fetch_api_change)
$rez = @ads_fetch_into($this->_queryID,$this->fields);
else {
$row = 0;
$rez = @ads_fetch_into($this->_queryID,$row,$this->fields);
}
if ($rez) {
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
}
return true;
}
}
$this->fields = false;
$this->EOF = true;
return false;
}
function _fetch()
{
if ($this->_has_stupid_odbc_fetch_api_change)
$rez = @ads_fetch_into($this->_queryID,$this->fields);
else {
$row = 0;
$rez = @ads_fetch_into($this->_queryID,$row,$this->fields);
}
if ($rez) {
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
}
return true;
}
$this->fields = false;
return false;
}
function _close()
{
return @ads_free_result($this->_queryID);
}
}
?>
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -72,7 +72,7 @@ class ADODB_csv extends ADOConnection {
return true;
}
function MetaColumns($table)
function MetaColumns($table, $normalize=true)
{
return false;
}
+44 -12
View File
@@ -24,6 +24,9 @@ if (!defined('ADODB_DIR')) die();
--------------------------------------------------------------------------------------*/
class ADODB_db2 extends ADOConnection {
var $databaseType = "db2";
var $fmtDate = "'Y-m-d'";
@@ -52,6 +55,7 @@ class ADODB_db2 extends ADOConnection {
var $uCaseTables = true; // for meta* functions, uppercase table names
var $hasInsertID = true;
function _insertid()
{
return ADOConnection::GetOne('VALUES IDENTITY_VAL_LOCAL()');
@@ -75,10 +79,14 @@ class ADODB_db2 extends ADOConnection {
// Replaces the odbc_binmode() call that was in Execute()
ini_set('ibm_db2.binmode', $this->binmode);
if ($argDatabasename) {
$this->_connectionID = db2_connect($argDatabasename,$argUsername,$argPassword);
if ($argDatabasename && empty($argDSN)) {
if (stripos($argDatabasename,'UID=') && stripos($argDatabasename,'PWD=')) $this->_connectionID = db2_connect($argDatabasename,null,null);
else $this->_connectionID = db2_connect($argDatabasename,$argUsername,$argPassword);
} else {
$this->_connectionID = db2_connect($argDSN,$argUsername,$argPassword);
if ($argDatabasename) $schema = $argDatabasename;
if (stripos($argDSN,'UID=') && stripos($argDSN,'PWD=')) $this->_connectionID = db2_connect($argDSN,null,null);
else $this->_connectionID = db2_connect($argDSN,$argUsername,$argPassword);
}
if (isset($php_errormsg)) $php_errormsg = '';
@@ -86,9 +94,9 @@ class ADODB_db2 extends ADOConnection {
// an array of valid options. So far, we don't use them.
$this->_errorMsg = @db2_conn_errormsg();
if (isset($this->connectStmt)) $this->Execute($this->connectStmt);
if ($this->_connectionID && isset($schema)) $this->Execute("SET SCHEMA=$schema");
return $this->_connectionID != false;
}
@@ -106,10 +114,14 @@ class ADODB_db2 extends ADOConnection {
if (isset($php_errormsg)) $php_errormsg = '';
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
if ($argDatabasename) {
$this->_connectionID = db2_pconnect($argDatabasename,$argUsername,$argPassword);
if ($argDatabasename && empty($argDSN)) {
if (stripos($argDatabasename,'UID=') && stripos($argDatabasename,'PWD=')) $this->_connectionID = db2_pconnect($argDatabasename,null,null);
else $this->_connectionID = db2_pconnect($argDatabasename,$argUsername,$argPassword);
} else {
$this->_connectionID = db2_pconnect($argDSN,$argUsername,$argPassword);
if ($argDatabasename) $schema = $argDatabasename;
if (stripos($argDSN,'UID=') && stripos($argDSN,'PWD=')) $this->_connectionID = db2_pconnect($argDSN,null,null);
else $this->_connectionID = db2_pconnect($argDSN,$argUsername,$argPassword);
}
if (isset($php_errormsg)) $php_errormsg = '';
@@ -117,6 +129,7 @@ class ADODB_db2 extends ADOConnection {
if ($this->_connectionID && $this->autoRollback) @db2_rollback($this->_connectionID);
if (isset($this->connectStmt)) $this->Execute($this->connectStmt);
if ($this->_connectionID && isset($schema)) $this->Execute("SET SCHEMA=$schema");
return $this->_connectionID != false;
}
@@ -223,7 +236,6 @@ class ADODB_db2 extends ADOConnection {
return ADOConnection::ServerInfo();
}
}
function CreateSequence($seqname='adodbseq',$start=1)
{
@@ -239,6 +251,25 @@ class ADODB_db2 extends ADOConnection {
return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
}
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);
} else {
if ($offset > 0 && $nrows < 0);
else {
$nrows += $offset;
$sql .= " FETCH FIRST $nrows ROWS ONLY ";
}
$rs = ADOConnection::SelectLimit($sql,-1,$offset,$inputArr);
}
return $rs;
}
/*
This algorithm is not very efficient, but works even if table locking
is not available.
@@ -407,7 +438,6 @@ class ADODB_db2 extends ADOConnection {
}
$arr = $rs->GetArray();
$rs->Close();
$arr2 = array();
@@ -417,12 +447,13 @@ class ADODB_db2 extends ADOConnection {
for ($i=0; $i < sizeof($arr); $i++) {
if (!$arr[$i][2]) continue;
$type = $arr[$i][3];
$owner = $arr[$i][1];
$schemaval = ($schema) ? $arr[$i][1].'.' : '';
if ($ttype) {
if ($isview) {
if (strncmp($type,'V',1) === 0) $arr2[] = $schemaval.$arr[$i][2];
} else if (strncmp($type,'SYS',3) !== 0) $arr2[] = $schemaval.$arr[$i][2];
} else if (strncmp($type,'SYS',3) !== 0) $arr2[] = $schemaval.$arr[$i][2];
} else if (strncmp($owner,'SYS',3) !== 0) $arr2[] = $schemaval.$arr[$i][2];
} else if (strncmp($owner,'SYS',3) !== 0) $arr2[] = $schemaval.$arr[$i][2];
}
return $arr2;
}
@@ -495,7 +526,7 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/db2/htm/db2
}
}
function MetaColumns($table)
function MetaColumns($table, $normalize=true)
{
global $ADODB_FETCH_MODE;
@@ -591,6 +622,7 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/db2/htm/db2
return $retarr;
}
function Prepare($sql)
{
if (! $this->_bindInputArray) return $sql; // no binding
+230
View File
@@ -0,0 +1,230 @@
<?php
/*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net
Microsoft Visual FoxPro data driver. Requires ODBC. Works only on MS Windows.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
include(ADODB_DIR."/drivers/adodb-db2.inc.php");
if (!defined('ADODB_DB2OCI')){
define('ADODB_DB2OCI',1);
/*
// regex code for smart remapping of :0, :1 bind vars to ? ?
function _colontrack($p)
{
global $_COLONARR,$_COLONSZ;
$v = (integer) substr($p,1);
if ($v > $_COLONSZ) return $p;
$_COLONARR[] = $v;
return '?';
}
// smart remapping of :0, :1 bind vars to ? ?
function _colonscope($sql,$arr)
{
global $_COLONARR,$_COLONSZ;
$_COLONARR = array();
$_COLONSZ = sizeof($arr);
$sql2 = preg_replace("/(:[0-9]+)/e","_colontrack('\\1')",$sql);
if (empty($_COLONARR)) return array($sql,$arr);
foreach($_COLONARR as $k => $v) {
$arr2[] = $arr[$v];
}
return array($sql2,$arr2);
}
*/
/*
Smart remapping of :0, :1 bind vars to ? ?
Handles colons in comments -- and / * * / and in quoted strings.
*/
function _colonparser($sql,$arr)
{
$lensql = strlen($sql);
$arrsize = sizeof($arr);
$state = 'NORM';
$at = 1;
$ch = $sql[0];
$ch2 = @$sql[1];
$sql2 = '';
$arr2 = array();
$nprev = 0;
while (strlen($ch)) {
switch($ch) {
case '/':
if ($state == 'NORM' && $ch2 == '*') {
$state = 'COMMENT';
$at += 1;
$ch = $ch2;
$ch2 = $at < $lensql ? $sql[$at] : '';
}
break;
case '*':
if ($state == 'COMMENT' && $ch2 == '/') {
$state = 'NORM';
$at += 1;
$ch = $ch2;
$ch2 = $at < $lensql ? $sql[$at] : '';
}
break;
case "\n":
case "\r":
if ($state == 'COMMENT2') $state = 'NORM';
break;
case "'":
do {
$at += 1;
$ch = $ch2;
$ch2 = $at < $lensql ? $sql[$at] : '';
} while ($ch !== "'");
break;
case ':':
if ($state == 'COMMENT' || $state == 'COMMENT2') break;
//echo "$at=$ch $ch2, ";
if ('0' <= $ch2 && $ch2 <= '9') {
$n = '';
$nat = $at;
do {
$at += 1;
$ch = $ch2;
$n .= $ch;
$ch2 = $at < $lensql ? $sql[$at] : '';
} while ('0' <= $ch && $ch <= '9');
#echo "$n $arrsize ] ";
$n = (integer) $n;
if ($n < $arrsize) {
$sql2 .= substr($sql,$nprev,$nat-$nprev-1).'?';
$nprev = $at-1;
$arr2[] = $arr[$n];
}
}
break;
case '-':
if ($state == 'NORM') {
if ($ch2 == '-') $state = 'COMMENT2';
$at += 1;
$ch = $ch2;
$ch2 = $at < $lensql ? $sql[$at] : '';
}
break;
}
$at += 1;
$ch = $ch2;
$ch2 = $at < $lensql ? $sql[$at] : '';
}
if ($nprev == 0) {
$sql2 = $sql;
} else {
$sql2 .= substr($sql,$nprev);
}
return array($sql2,$arr2);
}
class ADODB_db2oci extends ADODB_db2 {
var $databaseType = "db2oci";
var $sysTimeStamp = 'sysdate';
var $sysDate = 'trunc(sysdate)';
var $_bindInputArray = true;
function ADODB_db2oci()
{
parent::ADODB_db2();
}
function Param($name,$type=false)
{
return ':'.$name;
}
function MetaTables($ttype=false,$schema=false)
{
global $ADODB_FETCH_MODE;
$savem = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$qid = db2_tables($this->_connectionID);
$rs = new ADORecordSet_db2($qid);
$ADODB_FETCH_MODE = $savem;
if (!$rs) {
$false = false;
return $false;
}
$arr = $rs->GetArray();
$rs->Close();
$arr2 = array();
// adodb_pr($arr);
if ($ttype) {
$isview = strncmp($ttype,'V',1) === 0;
}
for ($i=0; $i < sizeof($arr); $i++) {
if (!$arr[$i][2]) continue;
$type = $arr[$i][3];
$schemaval = ($schema) ? $arr[$i][1].'.' : '';
$name = $schemaval.$arr[$i][2];
$owner = $arr[$i][1];
if (substr($name,0,8) == 'EXPLAIN_') continue;
if ($ttype) {
if ($isview) {
if (strncmp($type,'V',1) === 0) $arr2[] = $name;
} else if (strncmp($type,'T',1) === 0 && strncmp($owner,'SYS',3) !== 0) $arr2[] = $name;
} else if (strncmp($type,'T',1) === 0 && strncmp($owner,'SYS',3) !== 0) $arr2[] = $name;
}
return $arr2;
}
function _Execute($sql, $inputarr=false )
{
if ($inputarr) list($sql,$inputarr) = _colonparser($sql, $inputarr);
return parent::_Execute($sql, $inputarr);
}
};
class ADORecordSet_db2oci extends ADORecordSet_db2 {
var $databaseType = "db2oci";
function ADORecordSet_db2oci($id,$mode=false)
{
return $this->ADORecordSet_db2($id,$mode);
}
}
} //define
?>
+1 -1
View File
@@ -80,7 +80,7 @@ class ADODB_fbsql extends ADOConnection {
return true;
}
function MetaColumns($table)
function MetaColumns($table, $normalize=true)
{
if ($this->metaColumnsSQL) {
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+3 -3
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -242,7 +242,7 @@ class ADODB_ibase extends ADOConnection {
// See http://community.borland.com/article/0,1410,25844,00.html
function RowLock($tables,$where,$col)
function RowLock($tables,$where,$col=false)
{
if ($this->autoCommit) $this->BeginTrans();
$this->Execute("UPDATE $table SET $col=$col WHERE $where "); // is this correct - jlim?
@@ -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, $normalize=true)
{
global $ADODB_FETCH_MODE;
+5 -5
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim. All rights reserved.
V5.10 10 Nov 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,10 +123,10 @@ class ADODB_informix72 extends ADOConnection {
return true;
}
function RowLock($tables,$where,$flds='1 as ignore')
function RowLock($tables,$where,$col='1 as ignore')
{
if ($this->_autocommit) $this->BeginTrans();
return $this->GetOne("select $flds from $tables where $where for update");
return $this->GetOne("select $col from $tables where $where for update");
}
/* Returns: the last error message from previous database operation
@@ -147,7 +147,7 @@ class ADODB_informix72 extends ADOConnection {
}
function MetaColumns($table)
function MetaColumns($table, $normalize=true)
{
global $ADODB_FETCH_MODE;
@@ -369,7 +369,7 @@ class ADORecordset_informix72 extends ADORecordSet {
foreach($fp as $k => $v) {
$o = new ADOFieldObject;
$o->name = $k;
$arr = split(';',$v); //"SQLTYPE;length;precision;scale;ISNULLABLE"
$arr = explode(';',$v); //"SQLTYPE;length;precision;scale;ISNULLABLE"
$o->type = $arr[0];
$o->max_length = $arr[1];
$this->_fieldprops[] = $o;
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -61,7 +61,7 @@ class ADODB_ldap extends ADOConnection {
$conn_info = array( $host,$this->port);
if ( strstr( $host, ':' ) ) {
$conn_info = split( ':', $host );
$conn_info = explode( ':', $host );
}
$this->_connectionID = @ldap_connect( $conn_info[0], $conn_info[1] );
+40 -45
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -160,6 +160,41 @@ class ADODB_mssql extends ADOConnection {
}
}
/**
* Correctly quotes a string so that all strings are escaped. We prefix and append
* to the string single-quotes.
* An example is $db->qstr("Don't bother",magic_quotes_runtime());
*
* @param s the string to quote
* @param [magic_quotes] if $s is GET/POST var, set to get_magic_quotes_gpc().
* This undoes the stupidity of magic quotes for GPC.
*
* @return quoted string to be sent back to database
*/
function qstr($s,$magic_quotes=false)
{
if (!$magic_quotes) {
return "'".str_replace("'",$this->replaceQuote,$s)."'";
}
// undo magic quotes for " unless sybase is on
$sybase = ini_get('magic_quotes_sybase');
if (!$sybase) {
$s = str_replace('\\"','"',$s);
if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything
return "'$s'";
else {// change \' to '' for sybase/mssql
$s = str_replace('\\\\','\\',$s);
return "'".str_replace("\\'",$this->replaceQuote,$s)."'";
}
} else {
return "'".$s."'";
}
}
// moodle change end - see readme_moodle.txt
function _affectedrows()
{
return $this->GetOne('select @@rowcount');
@@ -331,14 +366,14 @@ class ADODB_mssql extends ADOConnection {
See http://www.swynk.com/friends/achigrik/SQL70Locks.asp
*/
function RowLock($tables,$where,$flds='top 1 null as ignore')
function RowLock($tables,$where,$col='top 1 null as ignore')
{
if (!$this->transCnt) $this->BeginTrans();
return $this->GetOne("select $flds from $tables with (ROWLOCK,HOLDLOCK) where $where");
return $this->GetOne("select $col from $tables with (ROWLOCK,HOLDLOCK) where $where");
}
function MetaIndexes($table,$primary=false)
function MetaIndexes($table,$primary=false, $owner=false)
{
$table = $this->qstr($table);
@@ -738,46 +773,6 @@ order by constraint_name, referenced_table_name, keyno";
}
return $rez;
}
// moodle change start - see readme_moodle.txt
/**
* Correctly quotes a string so that all strings are escaped. We prefix and append
* to the string single-quotes.
* An example is $db->qstr("Don't bother",magic_quotes_runtime());
*
* @param s the string to quote
* @param [magic_quotes] if $s is GET/POST var, set to get_magic_quotes_gpc().
* This undoes the stupidity of magic quotes for GPC.
*
* @return quoted string to be sent back to database
*/
function qstr($s,$magic_quotes=false)
{
if (!$magic_quotes) {
if ($this->replaceQuote[0] == '\\'){
// only since php 4.0.5
$s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
//$s = str_replace("\0","\\\0", str_replace('\\','\\\\',$s));
}
return "'".str_replace("'",$this->replaceQuote,$s)."'";
}
// undo magic quotes for " unless sybase is on
$sybase = ini_get('magic_quotes_sybase');
if (!$sybase) {
$s = str_replace('\\"','"',$s);
if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything
return "'$s'";
else {// change \' to '' for sybase/mssql
$s = str_replace('\\\\','\\',$s);
return "'".str_replace("\\'",$this->replaceQuote,$s)."'";
}
} else {
return "'".$s."'";
}
}
// moodle change end - see readme_moodle.txt
// returns true or false
function _close()
@@ -1101,4 +1096,4 @@ order by constraint_name, ordinal_position
http://www.databasejournal.com/scripts/article.php/1440551
*/
?>
?>
+3 -3
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -330,10 +330,10 @@ class ADODB_mssqlnative extends ADOConnection {
See http://www.swynk.com/friends/achigrik/SQL70Locks.asp
*/
function RowLock($tables,$where,$flds='top 1 null as ignore')
function RowLock($tables,$where,$col='top 1 null as ignore')
{
if (!$this->transCnt) $this->BeginTrans();
return $this->GetOne("select $flds from $tables with (ROWLOCK,HOLDLOCK) where $where");
return $this->GetOne("select $col from $tables with (ROWLOCK,HOLDLOCK) where $where");
}
function SelectDB($dbName)
+3 -3
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -349,7 +349,7 @@ class ADODB_mysql extends ADOConnection {
if (!$date) $date = $this->sysDate;
$fraction = $dayFraction * 24 * 3600;
return $date . ' + INTERVAL ' . $fraction.' SECOND';
return '('. $date . ' + INTERVAL ' . $fraction.' SECOND)';
// return "from_unixtime(unix_timestamp($date)+$fraction)";
}
@@ -394,7 +394,7 @@ class ADODB_mysql extends ADOConnection {
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
}
function MetaColumns($table)
function MetaColumns($table, $normalize=true)
{
$this->_findschema($table,$schema);
if ($schema) {
+34 -12
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -50,7 +50,8 @@ 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';
var $arrayClass = 'ADORecordSet_array_mysqli';
var $multiQuery = false;
function ADODB_mysqli()
{
@@ -194,11 +195,11 @@ class ADODB_mysqli extends ADOConnection {
return true;
}
function RowLock($tables,$where='',$flds='1 as adodb_ignore')
function RowLock($tables,$where='',$col='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 $col from $tables $where for update");
return !empty($rs);
}
@@ -526,7 +527,7 @@ class ADODB_mysqli extends ADOConnection {
return $foreign_keys;
}
function MetaColumns($table)
function MetaColumns($table, $normalize=true)
{
$false = false;
if (!$this->metaColumnsSQL)
@@ -684,15 +685,23 @@ class ADODB_mysqli extends ADOConnection {
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 )
if ($this->multiQuery) {
$rs = mysqli_multi_query($this->_connectionID, $sql.';');
if ($rs) {
$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;
$rs = mysqli_query($this->_connectionID, $sql, $ADODB_COUNTRECS ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT);
if ($rs) return $rs;
}
if($this->debug)
ADOConnection::outp("Query: " . $sql . " failed. " . $this->ErrorMsg());
return false;
}
/* Returns: the last error message from previous database operation */
@@ -947,6 +956,19 @@ class ADORecordSet_mysqli extends ADORecordSet{
function _close()
{
//if results are attached to this pointer from Stored Proceedure calls, the next standard query will die 2014
//only a problem with persistant connections
//mysqli_next_result($this->connection->_connectionID); trashes the DB side attached results.
while(mysqli_more_results($this->connection->_connectionID)){
@mysqli_next_result($this->connection->_connectionID);
}
//Because you can have one attached result, without tripping mysqli_more_results
@mysqli_next_result($this->connection->_connectionID);
mysqli_free_result($this->_queryID);
$this->_queryID = false;
}
+3 -3
View File
@@ -1,7 +1,7 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -59,11 +59,11 @@ class ADODB_mysqlt extends ADODB_mysql {
return true;
}
function RowLock($tables,$where='',$flds='1 as adodb_ignore')
function RowLock($tables,$where='',$col='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 $col from $tables $where for update");
return !empty($rs);
}
+3 -3
View File
@@ -1,7 +1,7 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -76,11 +76,11 @@ class ADODB_mysqlt extends ADODB_mysql {
return $ok ? true : false;
}
function RowLock($tables,$where='',$flds='1 as adodb_ignore')
function RowLock($tables,$where='',$col='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 $col from $tables $where for update");
return !empty($rs);
}
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 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.
+26 -17
View File
@@ -58,7 +58,7 @@ class ADODB_oci8 extends ADOConnection {
var $replaceQuote = "''"; // string to use to replace quotes
var $concat_operator='||';
var $sysDate = "TRUNC(SYSDATE)";
var $sysTimeStamp = 'SYSDATE';
var $sysTimeStamp = 'SYSDATE'; // requires oracle 9 or later, otherwise use SYSDATE
var $metaDatabasesSQL = "SELECT USERNAME FROM ALL_USERS WHERE USERNAME NOT IN ('SYS','SYSTEM','DBSNMP','OUTLN') ORDER BY 1";
var $_stmt;
var $_commit = OCI_COMMIT_ON_SUCCESS;
@@ -96,8 +96,8 @@ class ADODB_oci8 extends ADOConnection {
if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_';
}
/* function MetaColumns($table) added by [email protected]*/
function MetaColumns($table)
/* function MetaColumns($table, $normalize=true) added by [email protected]*/
function MetaColumns($table, $normalize=true)
{
global $ADODB_FETCH_MODE;
@@ -281,8 +281,13 @@ NATSOFT.DOMAIN =
{
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."')";
if (is_object($d)) $ds = $d->format($this->fmtDate);
else $ds = adodb_date($this->fmtDate,$d);
return "TO_DATE(".$ds.",'".$this->dateformat."')";
}
function BindDate($d)
@@ -293,12 +298,15 @@ NATSOFT.DOMAIN =
return substr($d,1,strlen($d)-2);
}
function BindTimeStamp($d)
function BindTimeStamp($ts)
{
$d = ADOConnection::DBTimeStamp($d);
if (strncmp($d,"'",1)) return $d;
if (empty($ts) && $ts !== 0) return 'null';
if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts);
return substr($d,1,strlen($d)-2);
if (is_object($ts)) $tss = $ts->format("'Y-m-d H:i:s'");
else $tss = adodb_date("'Y-m-d H:i:s'",$ts);
return $tss;
}
// format and return date string in database timestamp format
@@ -307,13 +315,17 @@ NATSOFT.DOMAIN =
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')";
if (is_object($ts)) $tss = $ts->format("'Y-m-d H:i:s'");
else $tss = adodb_date("'Y-m-d H:i:s'",$ts);
return 'TO_DATE('.$tss.",'RRRR-MM-DD, HH24:MI:SS')";
}
function RowLock($tables,$where,$flds='1 as ignore')
function RowLock($tables,$where,$col='1 as ignore')
{
if ($this->autoCommit) $this->BeginTrans();
return $this->GetOne("select $flds from $tables where $where for update");
return $this->GetOne("select $col from $tables where $where for update");
}
function MetaTables($ttype=false,$showSchema=false,$mask=false)
@@ -1282,18 +1294,15 @@ SELECT /*+ RULE */ distinct b.column_name
}
return "'".str_replace("'",$this->replaceQuote,$s)."'";
}
// moodle change start - see readme_moodle.txt
// undo magic quotes for " unless sybase is on
$sybase = ini_get('magic_quotes_sybase');
if (!$sybase) {
if (!ini_get('magic_quotes_sybase')) {
$s = str_replace('\\"','"',$s);
$s = str_replace('\\\\','\\',$s);
return "'".str_replace("\\'",$this->replaceQuote,$s)."'";
} else {
return "'".$s."'";
}
// moodle change end - see readme_moodle.txt
}
}
@@ -1551,7 +1560,7 @@ class ADORecordset_oci8 extends ADORecordSet {
case 'NCHAR':
case 'NVARCHAR':
case 'NVARCHAR2':
if (isset($this) && $len <= $this->blobSize) return 'C';
if ($len <= $this->blobSize) return 'C';
case 'NCLOB':
case 'LONG':
@@ -1604,4 +1613,4 @@ class ADORecordSet_ext_oci8 extends ADORecordSet_oci8 {
return adodb_movenext($this);
}
}
?>
?>
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim. All rights reserved.
V5.10 10 Nov 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.
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -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, $normalize=true)
{
global $ADODB_FETCH_MODE;
+3 -3
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -134,10 +134,10 @@ class ADODB_ODBC_DB2 extends ADODB_odbc {
return $this->GetOne($this->identitySQL);
}
function RowLock($tables,$where,$flds='1 as ignore')
function RowLock($tables,$where,$col='1 as ignore')
{
if ($this->_autocommit) $this->BeginTrans();
return $this->GetOne("select $flds from $tables where $where for update");
return $this->GetOne("select $col from $tables where $where for update");
}
function MetaTables($ttype=false,$showSchema=false, $qtable="%", $qschema="%")
+3 -3
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -130,14 +130,14 @@ order by constraint_name, referenced_table_name, keyno";
return $ret;
}
function MetaColumns($table)
function MetaColumns($table, $normalize=true)
{
$arr = ADOConnection::MetaColumns($table);
return $arr;
}
function MetaIndexes($table,$primary=false)
function MetaIndexes($table,$primary=false, $owner=false)
{
$table = $this->qstr($table);
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -50,7 +50,7 @@ class ADODB_odbc_oracle extends ADODB_odbc {
return $arr2;
}
function MetaColumns($table)
function MetaColumns($table, $normalize=true)
{
global $ADODB_FETCH_MODE;
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
@@ -541,7 +541,7 @@ class ADODB_odbtp extends ADOConnection{
return @odbtp_execute( $stmt ) != false;
}
function MetaIndexes($table,$primary=false)
function MetaIndexes($table,$primary=false, $owner=false)
{
switch ( $this->odbc_driver) {
case ODB_DRIVER_MSSQL:
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
+10 -6
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -35,15 +35,19 @@ class ADODB_oracle extends ADOConnection {
function DBDate($d)
{
if (is_string($d)) $d = ADORecordSet::UnixDate($d);
return 'TO_DATE('.adodb_date($this->fmtDate,$d).",'YYYY-MM-DD')";
if (is_object($d)) $ds = $d->format($this->fmtDate);
else $ds = adodb_date($this->fmtDate,$d);
return 'TO_DATE('.$ds.",'YYYY-MM-DD')";
}
// format and return date string in database timestamp format
function DBTimeStamp($ts)
{
if (is_string($ts)) $d = ADORecordSet::UnixTimeStamp($ts);
return 'TO_DATE('.adodb_date($this->fmtTimeStamp,$ts).",'RRRR-MM-DD, HH:MI:SS AM')";
if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts);
if (is_object($ts)) $ds = $ts->format($this->fmtDate);
else $ds = adodb_date($this->fmtTimeStamp,$ts);
return 'TO_DATE('.$ds.",'RRRR-MM-DD, HH:MI:SS AM')";
}
@@ -286,9 +290,9 @@ class ADORecordset_oracle extends ADORecordSet {
function _fetch($ignore_fields=false) {
// should remove call by reference, but ora_fetch_into requires it in 4.0.3pl1
if ($this->fetchMode & ADODB_FETCH_ASSOC)
return @ora_fetch_into($this->_queryID,&$this->fields,ORA_FETCHINTO_NULLS|ORA_FETCHINTO_ASSOC);
return @ora_fetch_into($this->_queryID,$this->fields,ORA_FETCHINTO_NULLS|ORA_FETCHINTO_ASSOC);
else
return @ora_fetch_into($this->_queryID,&$this->fields,ORA_FETCHINTO_NULLS);
return @ora_fetch_into($this->_queryID,$this->fields,ORA_FETCHINTO_NULLS);
}
/* close() only needs to be called if you are worried about using too much memory while your script
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+1 -1
View File
@@ -2,7 +2,7 @@
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+1 -1
View File
@@ -2,7 +2,7 @@
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+1 -1
View File
@@ -2,7 +2,7 @@
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+19 -6
View File
@@ -1,7 +1,7 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
@@ -27,12 +27,13 @@ class ADODB_pdo_sqlite extends ADODB_pdo {
var $_dropSeqSQL = 'DROP TABLE %s';
var $concat_operator = '||';
var $pdoDriver = false;
var $random='abs(random())';
function _init($parentDriver)
{
$this->pdoDriver = $parentDriver;
$parentDriver->_bindInputArray = true;
$parentDriver->hasTransactions = true;
$parentDriver->hasTransactions = false; // // should be set to false because of PDO SQLite driver not supporting changing autocommit mode
$parentDriver->hasInsertID = true;
}
@@ -40,7 +41,7 @@ class ADODB_pdo_sqlite extends ADODB_pdo {
{
$parent = $this->pdoDriver;
@($ver = array_pop($parent->GetCol("SELECT sqlite_version()")));
@($end = array_pop($parent->GetCol("PRAGMA encoding")));
@($enc = array_pop($parent->GetCol("PRAGMA encoding")));
$arr['version'] = $ver;
$arr['description'] = 'SQLite ';
@@ -143,7 +144,7 @@ class ADODB_pdo_sqlite extends ADODB_pdo {
// mark newnham
function MetaColumns($tab,$normalize=true))
function MetaColumns($tab,$normalize=true)
{
global $ADODB_FETCH_MODE;
@@ -184,7 +185,19 @@ class ADODB_pdo_sqlite extends ADODB_pdo {
function MetaTables($ttype=false,$showSchema=false,$mask=false)
{
$parent = $this->pdoDriver;
return $parent->GetCol($this->metaTablesSQL);
}
if ($mask) {
$save = $this->metaTablesSQL;
$mask = $this->qstr(strtoupper($mask));
$this->metaTablesSQL .= " AND name LIKE $mask";
}
$ret = $parent->GetCol($this->metaTablesSQL);
if ($mask) {
$this->metaTablesSQL = $save;
}
return $ret;
}
}
?>
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+11 -7
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -104,7 +104,8 @@ WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s'))
var $random = 'random()'; /// random function
var $autoRollback = true; // apparently pgsql does not autorollback properly before php 4.3.4
// http://bugs.php.net/bug.php?id=25404
var $uniqueIisR = true;
var $_bindInputArray = false; // requires postgresql 7.3+ and ability to modify database
var $disableBlobs = false; // set to true to disable blob checking, resulting in 2-5% improvement in performance.
@@ -177,10 +178,10 @@ a different OID if a database must be reloaded. */
return @pg_Exec($this->_connectionID, "begin ".$this->_transmode);
}
function RowLock($tables,$where,$flds='1 as ignore')
function RowLock($tables,$where,$col='1 as ignore')
{
if (!$this->transCnt) $this->BeginTrans();
return $this->GetOne("select $flds from $tables where $where for update");
return $this->GetOne("select $col from $tables where $where for update");
}
// returns true/false.
@@ -459,7 +460,10 @@ select viewname,'V' from pg_views where viewname like $mask";
if (10 <= $len && $len <= 12) $date = 'date '.$date;
else $date = 'timestamp '.$date;
}
return "($date+interval'$dayFraction days')";
return "($date+interval'".($dayFraction * 1440)." minutes')";
#return "($date+interval'$dayFraction days')";
}
@@ -661,7 +665,7 @@ WHERE (c2.relname=\'%s\' or c2.relname=lower(\'%s\'))';
if (strlen($db) == 0) $db = 'template1';
$db = adodb_addslashes($db);
if ($str) {
$host = split(":", $str);
$host = explode(":", $str);
if ($host[0]) $str = "host=".adodb_addslashes($host[0]);
else $str = '';
if (isset($host[1])) $str .= " port=$host[1]";
@@ -1052,7 +1056,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{
case 'INT4':
case 'INT2':
if (isset($fieldobj) &&
empty($fieldobj->primary_key) && empty($fieldobj->unique)) return 'I';
empty($fieldobj->primary_key) && (!$this->connection->uniqueIisR || empty($fieldobj->unique))) return 'I';
case 'OID':
case 'SERIAL':
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+3 -3
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
@@ -78,14 +78,14 @@ class ADODB_sqlite extends ADOConnection {
}
// mark newnham
function MetaColumns($tab)
function MetaColumns($table, $normalize=true)
{
global $ADODB_FETCH_MODE;
$false = false;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
$rs = $this->Execute("PRAGMA table_info('$tab')");
$rs = $this->Execute("PRAGMA table_info('$table')");
if (isset($savem)) $this->SetFetchMode($savem);
if (!$rs) {
$ADODB_FETCH_MODE = $save;
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+3 -3
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim. All rights reserved.
V5.10 10 Nov 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.
@@ -86,11 +86,11 @@ class ADODB_sybase extends ADOConnection {
}
// http://www.isug.com/Sybase_FAQ/ASE/section6.1.html#6.1.4
function RowLock($tables,$where,$flds='top 1 null as ignore')
function RowLock($tables,$where,$col='top 1 null as ignore')
{
if (!$this->_hastrans) $this->BeginTrans();
$tables = str_replace(',',' HOLDLOCK,',$tables);
return $this->GetOne("select $flds from $tables HOLDLOCK where $where");
return $this->GetOne("select $col from $tables HOLDLOCK where $where");
}
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
/*
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
+7 -11
View File
@@ -1,4 +1,8 @@
Description of ADODB V5.08 library import into Moodle
Description of ADODB V5.10 library import into Moodle
This library will be probably removed in Moodle 2.1,
it is now used only in enrol and auth db plugins.
The core DML drivers are not using ADODB any more.
Removed:
* contrib/
@@ -13,15 +17,7 @@ Added:
* index.html - prevent directory browsing on misconfigured servers
* readme_moodle.txt - this file ;-)
Our changes: /// Look for "moodle" in adodb code
* adodb-lib.inc.php - added support for "F" and "L" types in _adodb_column_sql()
* adodb-lib.inc.php - modify some debug output to be correct XHTML. MDL-12378.
Reported to ADOdb at: http://phplens.com/lens/lensforum/msgs.php?id=17133
Once fixed by adodb guys, we'll return to their official distro.
* drivers/adodb-mssql.inc.php, drivers/adodb-oci8.inc.php (qstr) and
adodb.inc.php (addq and qstr) - fixed wrong "undo magic quotes" that was
ignoring "magic_quotes_sybase" and leading to wrongly escaped contents. MDL-19452
Reported privately to John Lim, will be added to upstream soon. Once fixed
we'll return to their official distro.
Our changes:
* none
skodak, iarenaza, moodler, stronk7