Skip to content

Commit

Permalink
MDL-24551 importing latest adodb 5.11
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Oct 6, 2010
1 parent a02357d commit 6ede09a
Show file tree
Hide file tree
Showing 120 changed files with 499 additions and 950 deletions.
26 changes: 18 additions & 8 deletions lib/adodb/adodb-active-record.inc.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
@version V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
@version V5.11 5 May 2010 (c) 2000-2010 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 Down Expand Up @@ -345,8 +345,8 @@ function UpdateActiveTable($pkeys=false,$forceUpdate=false)
$tableat = $this->_tableat;
if (!$forceUpdate && !empty($tables[$tableat])) {

$tobj = $tables[$tableat];
foreach($tobj->flds as $name => $fld) {
$acttab = $tables[$tableat];
foreach($acttab->flds as $name => $fld) {
if ($ADODB_ACTIVE_DEFVALS && isset($fld->default_value))
$this->$name = $fld->default_value;
else
Expand All @@ -364,6 +364,14 @@ function UpdateActiveTable($pkeys=false,$forceUpdate=false)
if ($acttab->_created + $ADODB_ACTIVE_CACHESECS - (abs(rand()) % 16) > time()) {
// abs(rand()) randomizes deletion, reducing contention to delete/refresh file
// ideally, you should cache at least 32 secs

foreach($acttab->flds as $name => $fld) {
if ($ADODB_ACTIVE_DEFVALS && isset($fld->default_value))
$this->$name = $fld->default_value;
else
$this->$name = null;
}

$activedb->tables[$table] = $acttab;

//if ($db->debug) ADOConnection::outp("Reading cached active record file: $fname");
Expand Down Expand Up @@ -621,11 +629,13 @@ function LastInsertID(&$db,$fieldname)
function doquote(&$db, $val,$t)
{
switch($t) {
case 'D':
case 'L':
if (strpos($db->databaseType,'postgres') !== false) return $db->qstr($val);
case 'D':
case 'T':
if (empty($val)) return 'null';

case 'B':
case 'B':
case 'N':
case 'C':
case 'X':
Expand Down Expand Up @@ -889,10 +899,10 @@ function Update()
}
}
}
if (isset($this->_original[$i]) && $val == $this->_original[$i]) {

if (isset($this->_original[$i]) && strcmp($val,$this->_original[$i]) == 0) {
continue;
}
}
$valarr[] = $val;
$pairs[] = $this->_QName($name,$db).'='.$db->Param($cnt);
$cnt += 1;
Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-active-recordx.inc.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
@version V5.06 29 Sept 2008 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
@version V5.06 29 Sept 2008 (c) 2000-2010 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 Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-csvlib.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.11 5 May 2010 (c) 2000-2010 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
28 changes: 26 additions & 2 deletions lib/adodb/adodb-datadict.inc.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.11 5 May 2010 (c) 2000-2010 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 @@ -589,6 +589,8 @@ function CreateTableSQL($tabname, $flds, $tableoptions=array())

return $sql;
}



function _GenFields($flds,$widespacing=false)
{
Expand Down Expand Up @@ -913,6 +915,21 @@ function _Options($opts)
return $newopts;
}


function _getSizePrec($size)
{
$fsize = false;
$fprec = false;
$dotat = strpos($size,'.');
if ($dotat === false) $dotat = strpos($size,',');
if ($dotat === false) $fsize = $size;
else {
$fsize = substr($size,0,$dotat);
$fprec = substr($size,$dotat+1);
}
return array($fsize, $fprec);
}

/**
"Florian Buzin [ easywe ]" <florian.buzin#easywe.de>
Expand Down Expand Up @@ -958,9 +975,16 @@ function ChangeTableSQL($tablename, $flds, $tableoptions = false, $dropOldFlds=f
$c = $cols[$k];
$ml = $c->max_length;
$mt = $this->MetaType($c->type,$ml);

if (isset($c->scale)) $sc = $c->scale;
else $sc = 99; // always force change if scale not known.

if ($sc == -1) $sc = false;
list($fsize, $fprec) = $this->_getSizePrec($v['SIZE']);

if ($ml == -1) $ml = '';
if ($mt == 'X') $ml = $v['SIZE'];
if (($mt != $v['TYPE']) || $ml != $v['SIZE'] || (isset($v['AUTOINCREMENT']) && $v['AUTOINCREMENT'] != $obj->auto_increment)) {
if (($mt != $v['TYPE']) || ($ml != $fsize || $sc != $fprec) || (isset($v['AUTOINCREMENT']) && $v['AUTOINCREMENT'] != $obj->auto_increment)) {
$holdflds[$k] = $v;
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/adodb/adodb-error.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @version V5.06 16 Oct 2008 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
* @version V5.06 16 Oct 2008 (c) 2000-2010 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 @@ -99,7 +99,7 @@ function adodb_error_pg($errormsg)
'/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/i' => DB_ERROR_NOSUCHFIELD,
'/parser: parse error at or near \"/i' => DB_ERROR_SYNTAX,
'/referential integrity violation/i' => DB_ERROR_CONSTRAINT,
'/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key violates unique constraint/i'
'/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key.*violates unique constraint/i'
=> DB_ERROR_ALREADY_EXISTS
);
reset($error_regexps);
Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-errorhandler.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @version V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
* @version V5.11 5 May 2010 (c) 2000-2010 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-errorpear.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @version V5.06 16 Oct 2008 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
* @version V5.06 16 Oct 2008 (c) 2000-2010 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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* @version V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
* @version V5.11 5 May 2010 (c) 2000-2010 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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.11 5 May 2010 (c) 2000-2010 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
12 changes: 8 additions & 4 deletions lib/adodb/adodb-lib.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
$ADODB_INCLUDED_LIB = 1;

/*
@version V5.06 16 Oct 2008 (c) 2000-2009 John Lim (jlim\@natsoft.com.my). All rights reserved.
@version V5.06 16 Oct 2008 (c) 2000-2010 John Lim (jlim\@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Expand Down Expand Up @@ -455,9 +455,13 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)

if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) $rewritesql .= $limitarr[0];

$rstest = $zthis->Execute($rewritesql,$inputarr);
if (!$rstest) $rstest = $zthis->Execute($sql,$inputarr);

if ($secs2cache) {
$rstest = $zthis->CacheExecute($secs2cache,$rewritesql,$inputarr);
if (!$rstest) $rstest = $zthis->CacheExecute($secs2cache,$sql,$inputarr);
} else {
$rstest = $zthis->Execute($rewritesql,$inputarr);
if (!$rstest) $rstest = $zthis->Execute($sql,$inputarr);
}
if ($rstest) {
$qryRecs = $rstest->RecordCount();
if ($qryRecs == -1) {
Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-memcache.lib.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/*
V5.06 16 Oct 2008 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.06 16 Oct 2008 (c) 2000-2010 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
2 changes: 1 addition & 1 deletion lib/adodb/adodb-pager.inc.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.11 5 May 2010 (c) 2000-2010 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-pear.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @version V5.06 16 Oct 2008 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
* @version V5.06 16 Oct 2008 (c) 2000-2010 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-perf.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.11 5 May 2010 (c) 2000-2010 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
2 changes: 1 addition & 1 deletion lib/adodb/adodb-php4.inc.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
V5.11 5 May 2010 (c) 2000-2010 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
3 changes: 3 additions & 0 deletions lib/adodb/adodb-time.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,9 @@ function adodb_date($fmt,$d=false,$is_gmt=false)
*/
for ($i=0; $i < $max; $i++) {
switch($fmt[$i]) {
case 'e':
$dates .= date('e');
break;
case 'T':
if ($ADODB_DATETIME_CLASS) {
$dt = new DateTime();
Expand Down
10 changes: 6 additions & 4 deletions lib/adodb/adodb-xmlschema.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function _tag_close( &$parser, $tag ) {

}

function create() {
function create(&$xmls) {
return array();
}

Expand Down Expand Up @@ -1301,10 +1301,11 @@ class adoSchema {
*
* @param object $db ADOdb database connection object.
*/
function adoSchema( &$db ) {
function adoSchema( $db ) {
// Initialize the environment
$this->mgq = get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
ini_set("magic_quotes_runtime", 0);
#set_magic_quotes_runtime(0);

$this->db = $db;
$this->debug = $this->db->debug;
Expand Down Expand Up @@ -2193,7 +2194,8 @@ function getSQL( $format = NULL, $sqlArray = NULL ) {
* @deprecated adoSchema now cleans up automatically.
*/
function Destroy() {
set_magic_quotes_runtime( $this->mgq );
ini_set("magic_quotes_runtime", $this->mgq );
#set_magic_quotes_runtime( $this->mgq );
unset( $this );
}
}
Expand Down
10 changes: 6 additions & 4 deletions lib/adodb/adodb-xmlschema03.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function _tag_close( &$parser, $tag ) {

}

function create() {
function create(&$xmls) {
return array();
}

Expand Down Expand Up @@ -1405,10 +1405,11 @@ class adoSchema {
*
* @param object $db ADOdb database connection object.
*/
function adoSchema( &$db ) {
function adoSchema( $db ) {
// Initialize the environment
$this->mgq = get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
#set_magic_quotes_runtime(0);
ini_set("magic_quotes_runtime", 0);

$this->db = $db;
$this->debug = $this->db->debug;
Expand Down Expand Up @@ -2374,7 +2375,8 @@ function getSQL( $format = NULL, $sqlArray = NULL ) {
* @deprecated adoSchema now cleans up automatically.
*/
function Destroy() {
set_magic_quotes_runtime( $this->mgq );
ini_set("magic_quotes_runtime", $this->mgq );
#set_magic_quotes_runtime( $this->mgq );
unset( $this );
}
}
Expand Down
Loading

0 comments on commit 6ede09a

Please sign in to comment.