Skip to content

Commit

Permalink
MDL-20899 import latest adodb 5.10
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Nov 18, 2009
1 parent f2a0da6 commit 2d7f16e
Show file tree
Hide file tree
Showing 83 changed files with 1,395 additions and 1,785 deletions.
21 changes: 16 additions & 5 deletions lib/adodb/adodb-active-record.inc.php
@@ -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.
Expand All @@ -26,6 +26,7 @@
$_ADODB_ACTIVE_DBS = array();
$ACTIVE_RECORD_SAFETY = true;
$ADODB_ACTIVE_DEFVALS = false;
$ADODB_ACTIVE_CACHESECS = 0;

class ADODB_Active_DB {
var $db; // ADOConnection
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -655,6 +658,13 @@ function GenWhere(&$db, &$table)
}


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)
Expand Down Expand Up @@ -708,6 +718,7 @@ function Save()
return $ok;
}


// false on error
function Insert()
{
Expand All @@ -723,7 +734,7 @@ function Insert()
$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;
}
Expand Down Expand Up @@ -883,7 +894,7 @@ function Update()
continue;
}
$valarr[] = $val;
$pairs[] = $name.'='.$db->Param($cnt);
$pairs[] = $this->_QName($name,$db).'='.$db->Param($cnt);
$cnt += 1;
}

Expand Down Expand Up @@ -922,9 +933,9 @@ function adodb_GetActiveRecordsClass(&$db, $class, $table,$whereOrderBy,$bindarr
{
$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) {
Expand Down
3 changes: 2 additions & 1 deletion lib/adodb/adodb-csvlib.inc.php
Expand Up @@ -8,7 +8,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. See License.txt.
Expand Down Expand Up @@ -71,6 +71,7 @@ function _rs2serialize(&$rs,$conn=false,$sql='')
$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);
Expand Down
4 changes: 2 additions & 2 deletions lib/adodb/adodb-datadict.inc.php
@@ -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.
Expand Down Expand Up @@ -519,7 +519,7 @@ function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='')
// 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));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-errorhandler.inc.php
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-exceptions.inc.php
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-iterator.inc.php
@@ -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.
Expand Down
20 changes: 9 additions & 11 deletions lib/adodb/adodb-lib.inc.php
Expand Up @@ -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];
Expand Down Expand Up @@ -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);
Expand All @@ -1076,16 +1074,16 @@ 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);
}
}
} 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());
}
Expand All @@ -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();
Expand Down Expand Up @@ -1192,4 +1190,4 @@ function _adodb_find_from($sql)
}
*/

?>
?>
2 changes: 1 addition & 1 deletion lib/adodb/adodb-memcache.lib.inc.php
Expand Up @@ -65,7 +65,7 @@ function connect(&$err)

$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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-pager.inc.php
@@ -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.
Expand Down
8 changes: 3 additions & 5 deletions lib/adodb/adodb-perf.inc.php
@@ -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.
Expand Down Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-php4.inc.php
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-time.inc.php
Expand Up @@ -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)
);

Expand Down

0 comments on commit 2d7f16e

Please sign in to comment.