Navigation Menu

Skip to content

Commit

Permalink
backported new adodb 4.93 from HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Oct 16, 2006
1 parent 02d7853 commit 00d6980
Show file tree
Hide file tree
Showing 98 changed files with 235 additions and 178 deletions.
13 changes: 9 additions & 4 deletions lib/adodb/adodb-active-record.inc.php
@@ -1,7 +1,7 @@
<?php
/*
@version V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
@version V4.93 10 Oct 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). 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 @@ -41,7 +41,12 @@ function ADODB_SetDatabaseAdapter(&$db)
global $_ADODB_ACTIVE_DBS;

foreach($_ADODB_ACTIVE_DBS as $k => $d) {
if ($d->db == $db) return $k;
if (PHP_VERSION >= 5) {
if ($d->db == $db) return $k;
} else {
if ($d->db->_connectionID == $db->_connectionID && $db->database == $d->db->database)
return $k;
}
}

$obj = new ADODB_Active_DB();
Expand Down Expand Up @@ -218,12 +223,12 @@ function UpdateActiveTable($pkeys=false,$forceUpdate=false)
break;
default:
foreach($cols as $name => $fldobj) {
$name = ($name);
$name = ($fldobj->$name);
$this->$name = null;
$attr[$name] = $fldobj;
}
foreach($pkeys as $k => $name) {
$keys[$name] = ($name);
$keys[$name] = $cols[$name]->name;
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-csvlib.inc.php
Expand Up @@ -8,7 +8,7 @@

/*
V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
V4.93 10 Oct 2006 (c) 2000-2006 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
2 changes: 1 addition & 1 deletion lib/adodb/adodb-datadict.inc.php
@@ -1,7 +1,7 @@
<?php

/**
V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
V4.93 10 Oct 2006 (c) 2000-2006 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.
Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-error.inc.php
@@ -1,6 +1,6 @@
<?php
/**
* @version V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
* @version V4.93 10 Oct 2006 (c) 2000-2006 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.
Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-errorhandler.inc.php
@@ -1,6 +1,6 @@
<?php
/**
* @version V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
* @version V4.93 10 Oct 2006 (c) 2000-2006 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.
Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-errorpear.inc.php
@@ -1,6 +1,6 @@
<?php
/**
* @version V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
* @version V4.93 10 Oct 2006 (c) 2000-2006 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.
Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-exceptions.inc.php
@@ -1,7 +1,7 @@
<?php

/**
* @version V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
* @version V4.93 10 Oct 2006 (c) 2000-2006 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.
Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-iterator.inc.php
@@ -1,7 +1,7 @@
<?php

/*
V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
V4.93 10 Oct 2006 (c) 2000-2006 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.
Expand Down
12 changes: 6 additions & 6 deletions lib/adodb/adodb-lib.inc.php
Expand Up @@ -7,7 +7,7 @@
$ADODB_INCLUDED_LIB = 1;

/*
@version V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim\@natsoft.com.my). All rights reserved.
@version V4.93 10 Oct 2006 (c) 2000-2006 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 @@ -105,7 +105,7 @@ function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_
$keyCol = array($keyCol);
}
foreach($fieldArray as $k => $v) {
if ($autoQuote && !is_numeric($v) and strncmp($v,"'",1) !== 0 and strcasecmp($v,'null')!=0) {
if ($autoQuote && !is_numeric($v) and strncmp($v,"'",1) !== 0 and strcasecmp($v,$zthis->null2null)!=0) {
$v = $zthis->qstr($v);
$fieldArray[$k] = $v;
}
Expand Down Expand Up @@ -616,7 +616,7 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq
//********************************************************//
if (is_null($arrFields[$upperfname])
|| (empty($arrFields[$upperfname]) && strlen($arrFields[$upperfname]) == 0)
|| $arrFields[$upperfname] === 'null'
|| $arrFields[$upperfname] === $zthis->null2null
)
{
switch ($force) {
Expand All @@ -638,7 +638,7 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq
default:
case 3:
//Set the value that was given in array, so you can give both null and empty values
if (is_null($arrFields[$upperfname]) || $arrFields[$upperfname] === 'null') {
if (is_null($arrFields[$upperfname]) || $arrFields[$upperfname] === $zthis->null2null) {
$setFields .= $field->name . " = null, ";
} else {
$setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq,$arrFields, $magicq);
Expand Down Expand Up @@ -779,7 +779,7 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$force=2)
/********************************************************/
if (is_null($arrFields[$upperfname])
|| (empty($arrFields[$upperfname]) && strlen($arrFields[$upperfname]) == 0)
|| $arrFields[$upperfname] === 'null'
|| $arrFields[$upperfname] === $zthis->null2null
)
{
switch ($force) {
Expand All @@ -801,7 +801,7 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$force=2)
default:
case 3:
//Set the value that was given in array, so you can give both null and empty values
if (is_null($arrFields[$upperfname]) || $arrFields[$upperfname] === 'null') {
if (is_null($arrFields[$upperfname]) || $arrFields[$upperfname] === $zthis->null2null) {
$values .= "null, ";
} else {
$values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq, $arrFields, $magicq);
Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-pager.inc.php
@@ -1,7 +1,7 @@
<?php

/*
V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
V4.93 10 Oct 2006 (c) 2000-2006 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.
Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-pear.inc.php
@@ -1,6 +1,6 @@
<?php
/**
* @version V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
* @version V4.93 10 Oct 2006 (c) 2000-2006 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.
Expand Down
38 changes: 25 additions & 13 deletions lib/adodb/adodb-perf.inc.php
@@ -1,6 +1,6 @@
<?php
/*
V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
V4.93 10 Oct 2006 (c) 2000-2006 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 @@ -62,16 +62,28 @@ function adodb_microtime()
}

/* sql code timing */
function& adodb_log_sql(&$conn,$sql,$inputarr)
function& adodb_log_sql(&$connx,$sql,$inputarr)
{

$perf_table = adodb_perf::table();
$conn->fnExecute = false;
$connx->fnExecute = false;
$t0 = microtime();
$rs =& $conn->Execute($sql,$inputarr);
$rs =& $connx->Execute($sql,$inputarr);
$t1 = microtime();

if (!empty($conn->_logsql) && (empty($conn->_logsqlErrors) || !$rs)) {
if (!empty($connx->_logsql) && (empty($connx->_logsqlErrors) || !$rs)) {
global $ADODB_LOG_CONN;

if (!empty($ADODB_LOG_CONN)) {
$conn = &$ADODB_LOG_CONN;
if ($conn->databaseType != $connx->databaseType)
$prefix = '/*dbx='.$connx->databaseType .'*/ ';
else
$prefix = '';
} else {
$conn =& $connx;
$prefix = '';
}

$conn->_logsql = false; // disable logsql error simulation
$dbT = $conn->databaseType;

Expand All @@ -84,8 +96,8 @@ function& adodb_log_sql(&$conn,$sql,$inputarr)
$time = $a1 - $a0;

if (!$rs) {
$errM = $conn->ErrorMsg();
$errN = $conn->ErrorNo();
$errM = $connx->ErrorMsg();
$errN = $connx->ErrorNo();
$conn->lastInsID = 0;
$tracer = substr('ERROR: '.htmlspecialchars($errM),0,250);
} else {
Expand Down Expand Up @@ -126,6 +138,7 @@ function& adodb_log_sql(&$conn,$sql,$inputarr)
}

if (is_array($sql)) $sql = $sql[0];
if ($prefix) $sql = $prefix.$sql;
$arr = array('b'=>strlen($sql).'.'.crc32($sql),
'c'=>substr($sql,0,3900), 'd'=>$params,'e'=>$tracer,'f'=>adodb_round($time,6));
//var_dump($arr);
Expand All @@ -136,7 +149,7 @@ function& adodb_log_sql(&$conn,$sql,$inputarr)
if (empty($d)) $d = date("'Y-m-d H:i:s'");
if ($conn->dataProvider == 'oci8' && $dbT != 'oci8po') {
$isql = "insert into $perf_table values($d,:b,:c,:d,:e,:f)";
} else if ($dbT == 'odbc_mssql' || $dbT == 'informix' || $dbT == 'odbtp') {
} else if ($dbT == 'odbc_mssql' || $dbT == 'informix' || strncmp($dbT,'odbtp',4)==0) {
$timer = $arr['f'];
if ($dbT == 'informix') $sql2 = substr($sql2,0,230);

Expand All @@ -152,7 +165,6 @@ function& adodb_log_sql(&$conn,$sql,$inputarr)
if ($dbT == 'db2') $arr['f'] = (float) $arr['f'];
$isql = "insert into $perf_table (created,sql0,sql1,params,tracer,timer) values( $d,?,?,?,?,?)";
}

$ok = $conn->Execute($isql,$arr);
$conn->debug = $saved;

Expand All @@ -178,10 +190,10 @@ function& adodb_log_sql(&$conn,$sql,$inputarr)
$conn->_logsql = false;
}
}
$conn->_errorMsg = $errM;
$conn->_errorCode = $errN;
$connx->_errorMsg = $errM;
$connx->_errorCode = $errN;
}
$conn->fnExecute = 'adodb_log_sql';
$connx->fnExecute = 'adodb_log_sql';
return $rs;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-php4.inc.php
@@ -1,7 +1,7 @@
<?php

/*
V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
V4.93 10 Oct 2006 (c) 2000-2006 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.
Expand Down
47 changes: 27 additions & 20 deletions lib/adodb/adodb.inc.php
Expand Up @@ -14,7 +14,7 @@
/**
\mainpage
@version V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
@version V4.93 10 Oct 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. You can choose which license
you prefer.
Expand Down Expand Up @@ -110,7 +110,9 @@ class library to hide the differences between the different database API's (enca

// PHP's version scheme makes converting to numbers difficult - workaround
$_adodb_ver = (float) PHP_VERSION;
if ($_adodb_ver >= 5.0) {
if ($_adodb_ver >= 5.2) {
define('ADODB_PHPVER',0x5200);
} else if ($_adodb_ver >= 5.0) {
define('ADODB_PHPVER',0x5000);
} else if ($_adodb_ver > 4.299999) { # 4.3
define('ADODB_PHPVER',0x4300);
Expand Down Expand Up @@ -166,12 +168,13 @@ function ADODB_Setup()


// Initialize random number generator for randomizing cache flushes
srand(((double)microtime())*1000000);
// -- note Since PHP 4.2.0, the seed becomes optional and defaults to a random value if omitted.
srand(((double)microtime())*1000000);

/**
* ADODB version as a string.
*/
$ADODB_vers = 'V4.90 8 June 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.';
$ADODB_vers = 'V4.93 10 Oct 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.';

/**
* Determines whether recordset->RecordCount() is used.
Expand Down Expand Up @@ -305,6 +308,8 @@ class ADOConnection {
var $transCnt = 0; /// count of nested transactions

var $fetchMode=false;

var $null2null = 'null'; // in autoexecute/getinsertsql/getupdatesql, this value will be converted to a null
//
// PRIVATE VARS
//
Expand All @@ -323,6 +328,8 @@ class ADOConnection {
var $_logsql = false;
var $_transmode = ''; // transaction mode



/**
* Constructor
*/
Expand Down Expand Up @@ -1408,7 +1415,8 @@ function &GetArray($sql,$inputarr=false)

function &CacheGetAll($secs2cache,$sql=false,$inputarr=false)
{
return $this->CacheGetArray($secs2cache,$sql,$inputarr);
$arr =& $this->CacheGetArray($secs2cache,$sql,$inputarr);
return $arr;
}

function &CacheGetArray($secs2cache,$sql=false,$inputarr=false)
Expand Down Expand Up @@ -2937,8 +2945,12 @@ function &GetAssoc($force_array = false, $first2cols = false)
if ($ADODB_EXTENSION) {
if ($numIndex) {
while (!$this->EOF) {
// $results[trim($this->fields[0])] = array_slice($this->fields, 1);
// Fix for array_slice re-numbering numeric associative keys in PHP5
$results[trim($this->fields[0])] = array_slice($this->fields, 1);
adodb_movenext($this);
}
} else {
while (!$this->EOF) {
// Fix for array_slice re-numbering numeric associative keys
$keys = array_slice(array_keys($this->fields), 1);
$sliced_array = array();

Expand All @@ -2947,20 +2959,18 @@ function &GetAssoc($force_array = false, $first2cols = false)
}

$results[trim(reset($this->fields))] = $sliced_array;

adodb_movenext($this);
}
} else {
while (!$this->EOF) {
$results[trim(reset($this->fields))] = array_slice($this->fields, 1);
adodb_movenext($this);
}
}
} else {
if ($numIndex) {
while (!$this->EOF) {
//$results[trim($this->fields[0])] = array_slice($this->fields, 1);
// Fix for array_slice re-numbering numeric associative keys in PHP5
$results[trim($this->fields[0])] = array_slice($this->fields, 1);
$this->MoveNext();
}
} else {
while (!$this->EOF) {
// Fix for array_slice re-numbering numeric associative keys
$keys = array_slice(array_keys($this->fields), 1);
$sliced_array = array();

Expand All @@ -2971,11 +2981,6 @@ function &GetAssoc($force_array = false, $first2cols = false)
$results[trim(reset($this->fields))] = $sliced_array;
$this->MoveNext();
}
} else {
while (!$this->EOF) {
$results[trim(reset($this->fields))] = array_slice($this->fields, 1);
$this->MoveNext();
}
}
}
} else {
Expand Down Expand Up @@ -3548,6 +3553,8 @@ function MetaType($t,$len=-1,$fieldobj=false)
'DATE' => 'D',
'D' => 'D',
##
'UNIQUEIDENTIFIER' => 'C', # MS SQL Server
##
'TIME' => 'T',
'TIMESTAMP' => 'T',
'DATETIME' => 'T',
Expand Down

0 comments on commit 00d6980

Please sign in to comment.