This function changes/adds new fields to your table. You don't
have to know if the col is new or not. It will check on its own.
*/
function ChangeTableSQL($tablename, $flds, $tableoptions = false)
{
+ global $ADODB_FETCH_MODE;
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ if ($this->connection->fetchMode !== false) $savem = $this->connection->SetFetchMode(false);
+
// check table exists
$cols = &$this->MetaColumns($tablename);
+
+ if (isset($savem)) $this->connection->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+
if ( empty($cols)) {
return $this->CreateTableSQL($tablename, $flds, $tableoptions);
}
+ if (is_array($flds)) {
+ // Cycle through the update fields, comparing
+ // existing fields to fields to update.
+ // if the Metatype and size is exactly the
+ // same, ignore - by Mark Newham
+ $holdflds = array();
+ foreach($flds as $k=>$v) {
+ if ( isset($cols[$k]) && is_object($cols[$k]) ) {
+ $c = $cols[$k];
+ $ml = $c->max_length;
+ $mt = &$this->MetaType($c->type,$ml);
+ if ($ml == -1) $ml = '';
+ if ($mt == 'X') $ml = $v['SIZE'];
+ if (($mt != $v['TYPE']) || $ml != $v['SIZE']) {
+ $holdflds[$k] = $v;
+ }
+ } else {
+ $holdflds[$k] = $v;
+ }
+ }
+ $flds = $holdflds;
+ }
+
+
// already exists, alter table instead
list($lines,$pkey) = $this->_GenFields($flds);
$alter = 'ALTER TABLE ' . $this->TableName($tablename);
$sql = array();
-
+
foreach ( $lines as $id => $v ) {
if ( isset($cols[$id]) && is_object($cols[$id]) ) {
+
+ $flds = Lens_ParseArgs($v,',');
+
+ // We are trying to change the size of the field, if not allowed, simply ignore the request.
+ if ($flds && in_array(strtoupper(substr($flds[0][1],0,4)),$this->invalidResizeTypes4)) continue;
+
$sql[] = $alter . $this->alterCol . ' ' . $v;
} else {
$sql[] = $alter . $this->addCol . ' ' . $v;
diff --git a/lib/adodb/adodb-error.inc.php b/lib/adodb/adodb-error.inc.php
index c595d3b0ec7..081a3dd2570 100644
--- a/lib/adodb/adodb-error.inc.php
+++ b/lib/adodb/adodb-error.inc.php
@@ -1,6 +1,6 @@
Execute("select * from adoxyz");
foreach($rs as $k => $v) {
- echo $k; print_r($v); echo " ";
+ echo $k; print_r($v); echo " ";
}
@@ -73,6 +73,7 @@ class ADODB_BASE_RS implements IteratorAggregate {
return new ADODB_Iterator($this);
}
+ /* this is experimental - i don't really know what to return... */
function __toString()
{
include_once(ADODB_DIR.'/toexport.inc.php');
diff --git a/lib/adodb/adodb-lib.inc.php b/lib/adodb/adodb-lib.inc.php
index 38aaf236a8b..02f9a362939 100644
--- a/lib/adodb/adodb-lib.inc.php
+++ b/lib/adodb/adodb-lib.inc.php
@@ -7,7 +7,7 @@ global $ADODB_INCLUDED_LIB;
$ADODB_INCLUDED_LIB = 1;
/*
- @version V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim\@natsoft.com.my). All rights reserved.
+ @version V4.60 24 Jan 2005 (c) 2000-2005 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.
@@ -22,6 +22,7 @@ $ADODB_INCLUDED_LIB = 1;
function _array_change_key_case($an_array)
{
if (is_array($an_array)) {
+ $new_array = array();
foreach($an_array as $key=>$value)
$new_array[strtoupper($key)] = $value;
@@ -62,8 +63,10 @@ function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_
if ($uSet && $where) {
$update = "UPDATE $table SET $uSet WHERE $where";
+
+ $rs = $zthis->Execute($update);
+
- $rs = $zthis->_Execute($update);
if ($rs) {
if ($zthis->poorAffectedRows) {
/*
@@ -81,8 +84,10 @@ function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_
if (($zthis->Affected_Rows()>0)) return 1;
}
- }
+ } else
+ return 0;
}
+
// print "Error=".$this->ErrorNo().'
';
$first = true;
foreach($fieldArray as $k => $v) {
@@ -98,7 +103,7 @@ function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_
}
}
$insert = "INSERT INTO $table ($iCols) VALUES ($iVals)";
- $rs = $zthis->_Execute($insert);
+ $rs = $zthis->Execute($insert);
return ($rs) ? 2 : 0;
}
@@ -110,12 +115,12 @@ function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=f
if ($multiple or is_array($defstr)) {
if ($size==0) $size=5;
- $attr = " multiple size=$size";
+ $attr = ' multiple size="'.$size.'"';
if (!strpos($name,'[]')) $name .= '[]';
- } else if ($size) $attr = " size=$size";
+ } else if ($size) $attr = ' size="'.$size.'"';
else $attr ='';
-
- $s = "";
+
+ $s = '';
if ($blank1stItem)
if (is_string($blank1stItem)) {
$barr = explode(':',$blank1stItem);
@@ -179,7 +184,12 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
if ($zthis->dataProvider == 'oci8') {
$rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$sql);
- $rewritesql = "SELECT COUNT(*) FROM ($rewritesql)";
+
+ // Allow Oracle hints to be used for query optimization, Chris Wrye
+ if (preg_match('#/\\*+.*?\\*\\/#', $sql, $hint)) {
+ $rewritesql = "SELECT ".$hint[0]." COUNT(*) FROM (".$rewritesql.")";
+ } else
+ $rewritesql = "SELECT COUNT(*) FROM (".$rewritesql.")";
} else if ( $zthis->databaseType == 'postgres' || $zthis->databaseType == 'postgres7') {
@@ -218,7 +228,7 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
if (preg_match('/\s*UNION\s*/is', $sql)) $rewritesql = $sql;
else $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$sql);
- $rstest = &$zthis->_Execute($rewritesql,$inputarr);
+ $rstest = &$zthis->Execute($rewritesql,$inputarr);
if ($rstest) {
$qryRecs = $rstest->RecordCount();
if ($qryRecs == -1) {
@@ -355,7 +365,7 @@ function &_adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputar
return $rsreturn;
}
-function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq=false,$forcenulls=false)
+function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq=false,$force=2)
{
if (!$rs) {
printf(ADODB_BAD_RS,'GetUpdateSQL');
@@ -376,8 +386,8 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq
// If the recordset field is one
// of the fields passed in then process.
$upperfname = strtoupper($field->name);
- if (adodb_key_exists($upperfname,$arrFields,$forcenulls)) {
-
+ if (adodb_key_exists($upperfname,$arrFields,$force)) {
+
// If the existing field value in the recordset
// is different from the value passed in then
// go ahead and append the field name and new value to
@@ -398,20 +408,52 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq
// Format the value properly for the database
$type = $rs->MetaType($field->type);
- // is_null requires php 4.0.4
- if (($forcenulls && is_null($arrFields[$upperfname])) ||
- $arrFields[$upperfname] === 'null') {
- $setFields .= $field->name . " = null, ";
- } else {
- if ($type == 'null') {
- $type = 'C';
- }
-
- if (strpos($upperfname,' ') !== false)
- $fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote;
- else
- $fnameq = $upperfname;
+
+ if ($type == 'null') {
+ $type = 'C';
+ }
+
+ if (strpos($upperfname,' ') !== false)
+ $fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote;
+ else
+ $fnameq = $upperfname;
+
+
+ // is_null requires php 4.0.4
+ //********************************************************//
+ if (is_null($arrFields[$upperfname])
+ || (empty($arrFields[$upperfname]) && strlen($arrFields[$upperfname]) == 0)
+ || $arrFields[$upperfname] === 'null'
+ )
+ {
+ switch ($force) {
+
+ //case 0:
+ // //Ignore empty values. This is allready handled in "adodb_key_exists" function.
+ //break;
+
+ case 1:
+ //Set null
+ $setFields .= $field->name . " = null, ";
+ break;
+ case 2:
+ //Set empty
+ $arrFields[$upperfname] = "";
+ $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq,$arrFields, $magicq);
+ break;
+ 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') {
+ $setFields .= $field->name . " = null, ";
+ } else {
+ $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq,$arrFields, $magicq);
+ }
+ break;
+ }
+ //********************************************************//
+ } else {
//we do this so each driver can customize the sql for
//DB specific column types.
//Oracle needs BLOB types to be handled with a returning clause
@@ -436,7 +478,8 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq
// not a good hack, improvements?
if ($whereClause) {
if (preg_match('/\s(ORDER\s.*)/is', $whereClause[1], $discard));
- else preg_match('/\s(LIMIT\s.*)/is', $whereClause[1], $discard);
+ else if (preg_match('/\s(LIMIT\s.*)/is', $whereClause[1], $discard));
+ else preg_match('/\s(FOR UPDATE.*)/is', $whereClause[1], $discard);
} else
$whereClause = array(false,false);
@@ -454,9 +497,9 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq
}
}
-function adodb_key_exists($key, &$arr,$forcenulls=false)
+function adodb_key_exists($key, &$arr,$force=2)
{
- if (!$forcenulls) {
+ if ($force<=0) {
// the following is the old behaviour where null or empty fields are ignored
return (!empty($arr[$key])) || (isset($arr[$key]) && strlen($arr[$key])>0);
}
@@ -474,8 +517,12 @@ function adodb_key_exists($key, &$arr,$forcenulls=false)
*
*
*/
-function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$forcenulls=false)
+function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$force=2)
{
+static $cacheRS = false;
+static $cacheSig = 0;
+static $cacheCols;
+
$tableName = '';
$values = '';
$fields = '';
@@ -494,11 +541,24 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$forcenulls=f
$rsclass = $zthis->rsPrefix.$zthis->databaseType;
$recordSet =& new $rsclass(-1,$zthis->fetchMode);
$recordSet->connection = &$zthis;
-
- $columns = $zthis->MetaColumns( $tableName );
+
+ if (is_string($cacheRS) && $cacheRS == $rs) {
+ $columns =& $cacheCols;
+ } else {
+ $columns = $zthis->MetaColumns( $tableName );
+ $cacheRS = $tableName;
+ $cacheCols = $columns;
+ }
} else if (is_subclass_of($rs, 'adorecordset')) {
- for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++)
- $columns[] = $rs->FetchField($i);
+ if (isset($rs->insertSig) && is_integer($cacheRS) && $cacheRS == $rs->insertSig) {
+ $columns =& $cacheCols;
+ } else {
+ for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++)
+ $columns[] = $rs->FetchField($i);
+ $cacheRS = $cacheSig;
+ $cacheCols = $columns;
+ $rs->insertSig = $cacheSig++;
+ }
$recordSet =& $rs;
} else {
@@ -509,25 +569,49 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$forcenulls=f
// Loop through all of the fields in the recordset
foreach( $columns as $field ) {
$upperfname = strtoupper($field->name);
- if (adodb_key_exists($upperfname,$arrFields,$forcenulls)) {
-
- // Set the counter for the number of fields that will be inserted.
- $fieldInsertedCount++;
-
+ if (adodb_key_exists($upperfname,$arrFields,$force)) {
+ $bad = false;
if (strpos($upperfname,' ') !== false)
$fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote;
else
$fnameq = $upperfname;
-
- // Get the name of the fields to insert
- $fields .= $fnameq . ", ";
-
$type = $recordSet->MetaType($field->type);
+
+ /********************************************************/
+ if (is_null($arrFields[$upperfname])
+ || (empty($arrFields[$upperfname]) && strlen($arrFields[$upperfname]) == 0)
+ || $arrFields[$upperfname] === 'null'
+ )
+ {
+ switch ($force) {
+
+ case 0: // we must always set null if missing
+ $bad = true;
+ break;
+
+ case 1:
+ $values .= "null, ";
+ break;
- if (($forcenulls && is_null($arrFields[$upperfname])) ||
- $arrFields[$upperfname] === 'null') {
- $values .= "null, ";
+ case 2:
+ //Set empty
+ $arrFields[$upperfname] = "";
+ $values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq,$arrFields, $magicq);
+ break;
+
+ 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') {
+ $values .= "null, ";
+ } else {
+ $values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq, $arrFields, $magicq);
+ }
+ break;
+ } // switch
+
+ /*********************************************************/
} else {
//we do this so each driver can customize the sql for
//DB specific column types.
@@ -535,7 +619,15 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$forcenulls=f
//postgres has special needs as well
$values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq,
$arrFields, $magicq);
- }
+ }
+
+ if ($bad) continue;
+ // Set the counter for the number of fields that will be inserted.
+ $fieldInsertedCount++;
+
+
+ // Get the name of the fields to insert
+ $fields .= $fnameq . ", ";
}
}
@@ -724,7 +816,7 @@ global $HTTP_SERVER_VARS;
if ($inBrowser) {
$ss = htmlspecialchars($ss);
if ($zthis->debug === -1)
- ADOConnection::outp( " \n($zthis->databaseType): ".htmlspecialchars($sqlTxt)." $ss\n \n",false);
+ ADOConnection::outp( " \n($zthis->databaseType): ".htmlspecialchars($sqlTxt)." $ss\n \n",false);
else
ADOConnection::outp( " \n($zthis->databaseType): ".htmlspecialchars($sqlTxt)." $ss\n \n",false);
} else {
@@ -757,7 +849,7 @@ function _adodb_backtrace($printOrArr=true,$levels=9999)
$html = (isset($_SERVER['HTTP_USER_AGENT']));
$fmt = ($html) ? " %% line %4d, file: %s " : "%% line %4d, file: %s";
- $MAXSTRLEN = 64;
+ $MAXSTRLEN = 128;
$s = ($html) ? '' : '';
diff --git a/lib/adodb/adodb-pager.inc.php b/lib/adodb/adodb-pager.inc.php
index 09caa2671d4..eade0083558 100644
--- a/lib/adodb/adodb-pager.inc.php
+++ b/lib/adodb/adodb-pager.inc.php
@@ -1,7 +1,7 @@
rows = $rows;
+ if ($this->db->dataProvider == 'informix') $this->db->cursorType = IFX_SCROLL;
+
$savec = $ADODB_COUNTRECS;
if ($this->db->pageExecuteCountRows) $ADODB_COUNTRECS = true;
if ($this->cache)
diff --git a/lib/adodb/adodb-pear.inc.php b/lib/adodb/adodb-pear.inc.php
index 69de43966aa..c9c81bff35b 100644
--- a/lib/adodb/adodb-pear.inc.php
+++ b/lib/adodb/adodb-pear.inc.php
@@ -1,6 +1,6 @@
$v) {
switch(strtolower($k)) {
+ case 'persist':
case 'persistent': $persist = $v; break;
#ibase
case 'dialect': $obj->dialect = $v; break;
@@ -204,9 +210,10 @@ class DB
*/
function isError($value)
{
- return (is_object($value) &&
- (get_class($value) == 'db_error' ||
- is_subclass_of($value, 'db_error')));
+ if (!is_object($value)) return false;
+ $class = get_class($value);
+ return $class == 'pear_error' || is_subclass_of($value, 'pear_error') ||
+ $class == 'db_error' || is_subclass_of($value, 'db_error');
}
@@ -221,9 +228,11 @@ class DB
*/
function isWarning($value)
{
+ return false;
+ /*
return is_object($value) &&
(get_class( $value ) == "db_warning" ||
- is_subclass_of($value, "db_warning"));
+ is_subclass_of($value, "db_warning"));*/
}
/**
diff --git a/lib/adodb/adodb-perf.inc.php b/lib/adodb/adodb-perf.inc.php
index 3aad11aff58..f417d1620fe 100644
--- a/lib/adodb/adodb-perf.inc.php
+++ b/lib/adodb/adodb-perf.inc.php
@@ -1,6 +1,6 @@
debug = $dbg;
}
if (isset($HTTP_SERVER_VARS['HTTP_HOST'])) {
- $tracer .= ' '.$HTTP_SERVER_VARS['HTTP_HOST'];
+ $tracer .= ' '.$HTTP_SERVER_VARS['HTTP_HOST'];
if (isset($HTTP_SERVER_VARS['PHP_SELF'])) $tracer .= $HTTP_SERVER_VARS['PHP_SELF'];
} else
- if (isset($HTTP_SERVER_VARS['PHP_SELF'])) $tracer .= ' '.$HTTP_SERVER_VARS['PHP_SELF'];
+ if (isset($HTTP_SERVER_VARS['PHP_SELF'])) $tracer .= ' '.$HTTP_SERVER_VARS['PHP_SELF'];
//$tracer .= (string) adodb_backtrace(false);
- $tracer = substr($tracer,0,500);
+ $tracer = (string) substr($tracer,0,500);
if (is_array($inputarr)) {
if (is_array(reset($inputarr))) $params = 'Array sizeof='.sizeof($inputarr);
@@ -100,8 +100,10 @@ global $HTTP_SERVER_VARS;
$saved = $conn->debug;
$conn->debug = 0;
+ $d = $conn->sysTimeStamp;
+ if (empty($d)) $d = date("'Y-m-d H:i:s'");
if ($conn->dataProvider == 'oci8' && $dbT != 'oci8po') {
- $isql = "insert into $perf_table values($conn->sysTimeStamp,:b,:c,:d,:e,:f)";
+ $isql = "insert into $perf_table values($d,:b,:c,:d,:e,:f)";
} else if ($dbT == 'odbc_mssql' || $dbT == 'informix') {
$timer = $arr['f'];
if ($dbT == 'informix') $sql2 = substr($sql2,0,230);
@@ -111,12 +113,13 @@ global $HTTP_SERVER_VARS;
$params = $conn->qstr($arr['d']);
$tracer = $conn->qstr($arr['e']);
- $isql = "insert into $perf_table (created,sql0,sql1,params,tracer,timer) values($conn->sysTimeStamp,$sql1,$sql2,$params,$tracer,$timer)";
+ $isql = "insert into $perf_table (created,sql0,sql1,params,tracer,timer) values($d,$sql1,$sql2,$params,$tracer,$timer)";
if ($dbT == 'informix') $isql = str_replace(chr(10),' ',$isql);
$arr = false;
} else {
- $isql = "insert into $perf_table (created,sql0,sql1,params,tracer,timer) values( $conn->sysTimeStamp,?,?,?,?,?)";
+ $isql = "insert into $perf_table (created,sql0,sql1,params,tracer,timer) values( $d,?,?,?,?,?)";
}
+
$ok = $conn->Execute($isql,$arr);
$conn->debug = $saved;
@@ -138,7 +141,7 @@ global $HTTP_SERVER_VARS;
timer decimal(16,6))");
}
if (!$ok) {
- ADOConnection::outp( "LOGSQL Insert Failed : $isql $err2");
+ ADOConnection::outp( "LOGSQL Insert Failed : $isql $err2
");
$conn->_logsql = false;
}
}
@@ -293,7 +296,7 @@ Committed_AS: 348732 kB
$d_system = $info[2] - $last[2];
$d_idle = $info[3] - $last[3];
- //printf("Delta - User: %f Nice: %f System: %f Idle: %f ",$d_user,$d_nice,$d_system,$d_idle);
+ //printf("Delta - User: %f Nice: %f System: %f Idle: %f ",$d_user,$d_nice,$d_system,$d_idle);
if (strncmp(PHP_OS,'WIN',3)==0) {
if ($d_idle < 1) $d_idle = 1;
@@ -321,7 +324,7 @@ Committed_AS: 348732 kB
if ($arr) {
$s .= 'Scripts Affected ';
foreach($arr as $k) {
- $s .= sprintf("%4d",$k[0]).' '.strip_tags($k[1]).' ';
+ $s .= sprintf("%4d",$k[0]).' '.strip_tags($k[1]).' ';
}
}
$this->conn->fnExecute = $saveE;
@@ -379,6 +382,7 @@ Committed_AS: 348732 kB
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
//$this->conn->debug=1;
$rs =& $this->conn->SelectLimit(
"select avg(timer) as avg_timer,$sql1,count(*),max(timer) as max_timer,min(timer) as min_timer
@@ -387,12 +391,13 @@ Committed_AS: 348732 kB
and (tracer is null or tracer not like 'ERROR:%')
group by sql1
order by 1 desc",$numsql);
+ if (isset($savem)) $this->conn->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
$this->conn->fnExecute = $saveE;
if (!$rs) return "$this->helpurl. ".$this->conn->ErrorMsg()."
";
$s = "Suspicious SQL
-The following SQL have high average execution times
+The following SQL have high average execution times
Avg Time Count SQL Max Min \n";
$max = $this->maxLength;
while (!$rs->EOF) {
@@ -400,9 +405,9 @@ Committed_AS: 348732 kB
$raw = urlencode($sql);
if (strlen($raw)>$max-100) {
$sql2 = substr($sql,0,$max-500);
- $raw = urlencode($sql2).'&part='.crc32($sql);
+ $raw = urlencode($sql2).'&part='.crc32($sql);
}
- $prefix = "";
+ $prefix = " ";
$suffix = " ";
if ($this->explain == false || strlen($prefix)>$max) {
$suffix = ' ... String too long for GET parameter: '.strlen($prefix).' ';
@@ -456,6 +461,8 @@ Committed_AS: 348732 kB
$sql1 = $this->sql1;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
+
$rs =& $this->conn->SelectLimit(
"select sum(timer) as total,$sql1,count(*),max(timer) as max_timer,min(timer) as min_timer
from $perf_table
@@ -463,12 +470,12 @@ Committed_AS: 348732 kB
and (tracer is null or tracer not like 'ERROR:%')
group by sql1
order by 1 desc",$numsql);
-
+ if (isset($savem)) $this->conn->SetFetchMode($savem);
$this->conn->fnExecute = $saveE;
$ADODB_FETCH_MODE = $save;
if (!$rs) return "$this->helpurl. ".$this->conn->ErrorMsg()."
";
$s = "Expensive SQL
-Tuning the following SQL will reduce the server load substantially
+Tuning the following SQL will reduce the server load substantially
Load Count SQL Max Min \n";
$max = $this->maxLength;
while (!$rs->EOF) {
@@ -476,9 +483,9 @@ Committed_AS: 348732 kB
$raw = urlencode($sql);
if (strlen($raw)>$max-100) {
$sql2 = substr($sql,0,$max-500);
- $raw = urlencode($sql2).'&part='.crc32($sql);
+ $raw = urlencode($sql2).'&part='.crc32($sql);
}
- $prefix = "";
+ $prefix = " ";
$suffix = " ";
if($this->explain == false || strlen($prefix>$max)) {
$prefix = '';
@@ -639,7 +646,7 @@ Committed_AS: 348732 kB
break;
case 'poll':
echo "";
+ src=\"{$HTTP_SERVER_VARS['PHP_SELF']}?do=poll2&hidem=1\">";
break;
case 'poll2':
echo "";
@@ -653,7 +660,7 @@ Committed_AS: 348732 kB
break;
case 'viewsql':
if (empty($HTTP_GET_VARS['hidem']))
- echo " Clear SQL Log ";
+ echo " Clear SQL Log ";
echo($this->SuspiciousSQL($nsql));
echo($this->ExpensiveSQL($nsql));
echo($this->InvalidSQL($nsql));
@@ -679,6 +686,7 @@ Committed_AS: 348732 kB
set_time_limit(0);
sleep($secs);
while (1) {
+
$arr =& $this->PollParameters();
$hits = sprintf('%2.2f',$arr[0]);
@@ -699,6 +707,8 @@ Committed_AS: 348732 kB
echo date('H:i:s').' '.$osval."$hits $sess $reads $writes\n";
flush();
+ if (connection_aborted()) return;
+
sleep($secs);
$arro = $arr;
}
@@ -880,7 +890,7 @@ Committed_AS: 348732 kB
if (empty($e1)) $e1 = '-1'; // postgresql fix
print ' '.$e1.': '.$e2;
} else {
- print "No Recordset returned
";
+ print "No Recordset returned
";
}
}
} // foreach
diff --git a/lib/adodb/adodb-php4.inc.php b/lib/adodb/adodb-php4.inc.php
index 13925b5632a..e63a570fd5d 100644
--- a/lib/adodb/adodb-php4.inc.php
+++ b/lib/adodb/adodb-php4.inc.php
@@ -1,7 +1,7 @@
$y1 error ";
+ print "$y1 error ";
return false;
}
return true;
@@ -318,57 +327,57 @@ function adodb_date_test()
if (!defined('ADODB_TEST_DATES')) define('ADODB_TEST_DATES',1);
$t = adodb_mktime(0,0,0);
- if (!(adodb_date('Y-m-d') == date('Y-m-d'))) print 'Error in '.adodb_mktime(0,0,0).' ';
+ if (!(adodb_date('Y-m-d') == date('Y-m-d'))) print 'Error in '.adodb_mktime(0,0,0).' ';
$t = adodb_mktime(0,0,0,6,1,2102);
- if (!(adodb_date('Y-m-d',$t) == '2102-06-01')) print 'Error in '.adodb_date('Y-m-d',$t).' ';
+ if (!(adodb_date('Y-m-d',$t) == '2102-06-01')) print 'Error in '.adodb_date('Y-m-d',$t).' ';
$t = adodb_mktime(0,0,0,2,1,2102);
- if (!(adodb_date('Y-m-d',$t) == '2102-02-01')) print 'Error in '.adodb_date('Y-m-d',$t).' ';
+ if (!(adodb_date('Y-m-d',$t) == '2102-02-01')) print 'Error in '.adodb_date('Y-m-d',$t).' ';
print "Testing gregorian <=> julian conversion
";
$t = adodb_mktime(0,0,0,10,11,1492);
//http://www.holidayorigins.com/html/columbus_day.html - Friday check
- if (!(adodb_date('D Y-m-d',$t) == 'Fri 1492-10-11')) print 'Error in Columbus landing ';
+ if (!(adodb_date('D Y-m-d',$t) == 'Fri 1492-10-11')) print 'Error in Columbus landing ';
$t = adodb_mktime(0,0,0,2,29,1500);
- if (!(adodb_date('Y-m-d',$t) == '1500-02-29')) print 'Error in julian leap years ';
+ if (!(adodb_date('Y-m-d',$t) == '1500-02-29')) print 'Error in julian leap years ';
$t = adodb_mktime(0,0,0,2,29,1700);
- if (!(adodb_date('Y-m-d',$t) == '1700-03-01')) print 'Error in gregorian leap years ';
+ if (!(adodb_date('Y-m-d',$t) == '1700-03-01')) print 'Error in gregorian leap years ';
print adodb_mktime(0,0,0,10,4,1582).' ';
print adodb_mktime(0,0,0,10,15,1582);
$diff = (adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582));
- if ($diff != 3600*24) print " Error in gregorian correction = ".($diff/3600/24)." days ";
+ if ($diff != 3600*24) print " Error in gregorian correction = ".($diff/3600/24)." days ";
- print " 15 Oct 1582, Fri=".(adodb_dow(1582,10,15) == 5 ? 'Fri' : 'Error ')." ";
- print " 4 Oct 1582, Thu=".(adodb_dow(1582,10,4) == 4 ? 'Thu' : 'Error ')." ";
+ print " 15 Oct 1582, Fri=".(adodb_dow(1582,10,15) == 5 ? 'Fri' : 'Error ')." ";
+ print " 4 Oct 1582, Thu=".(adodb_dow(1582,10,4) == 4 ? 'Thu' : 'Error ')." ";
print "
Testing overflow
";
$t = adodb_mktime(0,0,0,3,33,1965);
- if (!(adodb_date('Y-m-d',$t) == '1965-04-02')) print 'Error in day overflow 1 ';
+ if (!(adodb_date('Y-m-d',$t) == '1965-04-02')) print 'Error in day overflow 1 ';
$t = adodb_mktime(0,0,0,4,33,1971);
- if (!(adodb_date('Y-m-d',$t) == '1971-05-03')) print 'Error in day overflow 2 ';
+ if (!(adodb_date('Y-m-d',$t) == '1971-05-03')) print 'Error in day overflow 2 ';
$t = adodb_mktime(0,0,0,1,60,1965);
- if (!(adodb_date('Y-m-d',$t) == '1965-03-01')) print 'Error in day overflow 3 '.adodb_date('Y-m-d',$t).' ';
+ if (!(adodb_date('Y-m-d',$t) == '1965-03-01')) print 'Error in day overflow 3 '.adodb_date('Y-m-d',$t).' ';
$t = adodb_mktime(0,0,0,12,32,1965);
- if (!(adodb_date('Y-m-d',$t) == '1966-01-01')) print 'Error in day overflow 4 '.adodb_date('Y-m-d',$t).' ';
+ if (!(adodb_date('Y-m-d',$t) == '1966-01-01')) print 'Error in day overflow 4 '.adodb_date('Y-m-d',$t).' ';
$t = adodb_mktime(0,0,0,12,63,1965);
- if (!(adodb_date('Y-m-d',$t) == '1966-02-01')) print 'Error in day overflow 5 '.adodb_date('Y-m-d',$t).' ';
+ if (!(adodb_date('Y-m-d',$t) == '1966-02-01')) print 'Error in day overflow 5 '.adodb_date('Y-m-d',$t).' ';
$t = adodb_mktime(0,0,0,13,3,1965);
- if (!(adodb_date('Y-m-d',$t) == '1966-01-03')) print 'Error in mth overflow 1 ';
+ if (!(adodb_date('Y-m-d',$t) == '1966-01-03')) print 'Error in mth overflow 1 ';
print "Testing 2-digit => 4-digit year conversion
";
- if (adodb_year_digit_check(00) != 2000) print "Err 2-digit 2000 ";
- if (adodb_year_digit_check(10) != 2010) print "Err 2-digit 2010 ";
- if (adodb_year_digit_check(20) != 2020) print "Err 2-digit 2020 ";
- if (adodb_year_digit_check(30) != 2030) print "Err 2-digit 2030 ";
- if (adodb_year_digit_check(40) != 1940) print "Err 2-digit 1940 ";
- if (adodb_year_digit_check(50) != 1950) print "Err 2-digit 1950 ";
- if (adodb_year_digit_check(90) != 1990) print "Err 2-digit 1990 ";
+ if (adodb_year_digit_check(00) != 2000) print "Err 2-digit 2000 ";
+ if (adodb_year_digit_check(10) != 2010) print "Err 2-digit 2010 ";
+ if (adodb_year_digit_check(20) != 2020) print "Err 2-digit 2020 ";
+ if (adodb_year_digit_check(30) != 2030) print "Err 2-digit 2030 ";
+ if (adodb_year_digit_check(40) != 1940) print "Err 2-digit 1940 ";
+ if (adodb_year_digit_check(50) != 1950) print "Err 2-digit 1950 ";
+ if (adodb_year_digit_check(90) != 1990) print "Err 2-digit 1990 ";
// Test string formating
print "
Testing date formating
";
@@ -376,7 +385,7 @@ function adodb_date_test()
$s1 = date($fmt,0);
$s2 = adodb_date($fmt,0);
if ($s1 != $s2) {
- print " date() 0 failed $s1 $s2 ";
+ print " date() 0 failed $s1 $s2 ";
}
flush();
for ($i=100; --$i > 0; ) {
@@ -384,7 +393,7 @@ function adodb_date_test()
$ts = 3600.0*((rand()%60000)+(rand()%60000))+(rand()%60000);
$s1 = date($fmt,$ts);
$s2 = adodb_date($fmt,$ts);
- //print "$s1 $s2 ";
+ //print "$s1 $s2
";
$pos = strcmp($s1,$s2);
if (($s1) != ($s2)) {
@@ -394,9 +403,9 @@ function adodb_date_test()
break;
}
}
- print "Error date(): $ts
+ print "Error date(): $ts
\"$s1\" (date len=".strlen($s1).")
- \"$s2\" (adodb_date len=".strlen($s2).") ";
+ \"$s2\" (adodb_date len=".strlen($s2).")
";
$fail = true;
}
@@ -404,9 +413,9 @@ function adodb_date_test()
$a2 = adodb_getdate($ts);
$rez = array_diff($a1,$a2);
if (sizeof($rez)>0) {
- print "Error getdate() $ts ";
+ print "Error getdate() $ts ";
print_r($a1);
- print " ";
+ print " ";
print_r($a2);
print "";
$fail = true;
@@ -452,7 +461,7 @@ function adodb_date_test()
}
$cnt += 1;
}
- echo "Tested $cnt dates ";
+ echo "Tested $cnt dates ";
if (!$fail) print "
Passed !
";
else print "Failed :-(
";
}
@@ -485,13 +494,13 @@ Thursday, October 4, 1582 (Julian) was followed immediately by Friday, October 1
$year--;
}
- $day = ( floor((13 * $month - 1) / 5) +
+ $day = floor((13 * $month - 1) / 5) +
$day + ($year % 100) +
floor(($year % 100) / 4) +
floor(($year / 100) / 4) - 2 *
- floor($year / 100) + 77);
+ floor($year / 100) + 77 + $greg_correction;
- return (($day - 7 * floor($day / 7))) + $greg_correction;
+ return $day - 7 * floor($day / 7);
}
@@ -597,7 +606,7 @@ function _adodb_getdate($origd=false,$fast=false,$is_gmt=false)
$d365 = $_day_power * 365;
if ($d < 0) {
- $origd = $d;
+ if ($is_gmt) $origd = $d;
// The valid range of a 32bit signed timestamp is typically from
// Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT
for ($a = 1970 ; --$a >= 0;) {
@@ -611,7 +620,6 @@ function _adodb_getdate($origd=false,$fast=false,$is_gmt=false)
break;
}
}
-
$secsInYear = 86400 * ($leaf ? 366 : 365) + $lastd;
$d = $lastd;
@@ -793,7 +801,7 @@ static $daylight;
case 'S':
$d10 = $day % 10;
if ($d10 == 1) $dates .= 'st';
- else if ($d10 == 2) $dates .= 'nd';
+ else if ($d10 == 2 && $day != 12) $dates .= 'nd';
else if ($d10 == 3) $dates .= 'rd';
else $dates .= 'th';
break;
@@ -877,22 +885,31 @@ function adodb_gmmktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=
function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false,$is_gmt=false)
{
if (!defined('ADODB_TEST_DATES')) {
+
+ if ($mon === false) {
+ return $is_gmt? @gmmktime($hr,$min,$sec): @mktime($hr,$min,$sec);
+ }
+
// for windows, we don't check 1970 because with timezone differences,
// 1 Jan 1970 could generate negative timestamp, which is illegal
if (1971 < $year && $year < 2038
- || $mon === false
|| !defined('ADODB_NO_NEGATIVE_TS') && (1901 < $year && $year < 2038)
- )
- return $is_gmt?
+ ) {
+ return $is_gmt ?
@gmmktime($hr,$min,$sec,$mon,$day,$year):
@mktime($hr,$min,$sec,$mon,$day,$year);
+ }
}
$gmt_different = ($is_gmt) ? 0 : adodb_get_gmt_diff();
-
+
+ /*
+ # disabled because some people place large values in $sec.
+ # however we need it for $mon because we use an array...
$hr = intval($hr);
$min = intval($min);
$sec = intval($sec);
+ */
$mon = intval($mon);
$day = intval($day);
$year = intval($year);
diff --git a/lib/adodb/adodb-xmlschema.inc.php b/lib/adodb/adodb-xmlschema.inc.php
index a395de7074c..a84cbc0365d 100644
--- a/lib/adodb/adodb-xmlschema.inc.php
+++ b/lib/adodb/adodb-xmlschema.inc.php
@@ -1917,7 +1917,7 @@ class adoSchema {
$schema .= ' ' . "\n";
// grab details from database
- $rs = $this->db->Execute( 'SELECT * FROM ' . $table . ' WHERE -1' );
+ $rs = $this->db->Execute( 'SELECT * FROM ' . $table . ' WHERE 1=1' );
$fields = $this->db->MetaColumns( $table );
$indexes = $this->db->MetaIndexes( $table );
@@ -1983,7 +1983,7 @@ class adoSchema {
while( $row = $rs->FetchRow() ) {
foreach( $row as $key => $val ) {
- $row[$key] = htmlentities($row);
+ $row[$key] = htmlentities($val);
}
$schema .= ' ' . implode( ' ', $row ) . '
' . "\n";
diff --git a/lib/adodb/adodb.inc.php b/lib/adodb/adodb.inc.php
index dfec7f16671..8a3e21fece1 100644
--- a/lib/adodb/adodb.inc.php
+++ b/lib/adodb/adodb.inc.php
@@ -14,7 +14,7 @@
/**
\mainpage
- @version V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim\@natsoft.com.my). All rights reserved.
+ @version V4.60 24 Jan 2005 (c) 2000-2005 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.
@@ -26,9 +26,9 @@
We currently support MySQL, Oracle, Microsoft SQL Server, Sybase, Sybase SQL Anywhere, DB2,
Informix, PostgreSQL, FrontBase, Interbase (Firebird and Borland variants), Foxpro, Access,
ADO, SAP DB, SQLite and ODBC. We have had successful reports of connecting to Progress and
- other databases via ODBC.
-
- Latest Download at http://php.weblogs.com/adodb
+ other databases via ODBC.
+
+ Latest Download at http://php.weblogs.com/adodb
Manual is at http://php.weblogs.com/adodb_manual
*/
@@ -64,12 +64,30 @@
//==============================================================================================
$ADODB_EXTENSION = defined('ADODB_EXTENSION');
+
+ //********************************************************//
+ /*
+ Controls $ADODB_FORCE_TYPE mode. Default is ADODB_FORCE_VALUE (3).
+ Used in GetUpdateSql and GetInsertSql functions. Thx to Niko, nuko#mbnet.fi
+
+ 0 = ignore empty fields. All empty fields in array are ignored.
+ 1 = force null. All empty, php null and string 'null' fields are changed to sql NULL values.
+ 2 = force empty. All empty, php null and string 'null' fields are changed to sql empty '' or 0 values.
+ 3 = force value. Value is left as it is. Php null and string 'null' are set to sql NULL values and empty fields '' are set to empty '' sql values.
+ */
+ define('ADODB_FORCE_IGNORE',0);
+ define('ADODB_FORCE_NULL',1);
+ define('ADODB_FORCE_EMPTY',2);
+ define('ADODB_FORCE_VALUE',3);
+ //********************************************************//
+
+
if (!$ADODB_EXTENSION || ADODB_EXTENSION < 4.0) {
define('ADODB_BAD_RS','Bad $rs in %s. Connection or SQL invalid. Try using $connection->debug=true;
');
// allow [ ] @ ` " and . in table names
- define('ADODB_TABLE_REGEX','([]0-9a-z_\"\`\.\@\[-]*)');
+ define('ADODB_TABLE_REGEX','([]0-9a-z_\:\"\`\.\@\[-]*)');
// prefetching used by oracle
if (!defined('ADODB_PREFETCH_ROWS')) define('ADODB_PREFETCH_ROWS',10);
@@ -132,10 +150,13 @@
$ADODB_vers, // database version
$ADODB_COUNTRECS, // count number of records returned - slows down query
$ADODB_CACHE_DIR, // directory to cache recordsets
- $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE,
+ $ADODB_FORCE_TYPE;
$ADODB_FETCH_MODE = ADODB_FETCH_DEFAULT;
-
+ $ADODB_FORCE_TYPE = ADODB_FORCE_VALUE;
+
+
if (!isset($ADODB_CACHE_DIR)) {
$ADODB_CACHE_DIR = '/tmp'; //(isset($_ENV['TMP'])) ? $_ENV['TMP'] : '/tmp';
} else {
@@ -151,7 +172,7 @@
/**
* ADODB version as a string.
*/
- $ADODB_vers = 'V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.';
+ $ADODB_vers = 'V4.60 24 Jan 2005 (c) 2000-2005 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.';
/**
* Determines whether recordset->RecordCount() is used.
@@ -219,7 +240,7 @@
var $user = ''; /// The username which is used to connect to the database server.
var $password = ''; /// Password for the username. For security, we no longer store it.
var $debug = false; /// if set to true will output sql statements
- var $maxblobsize = 256000; /// maximum size of blobs or large text fields -- some databases die otherwise like foxpro
+ var $maxblobsize = 262144; /// maximum size of blobs or large text fields (262144 = 256K)-- some db's die otherwise like foxpro
var $concat_operator = '+'; /// default concat operator -- change to || for Oracle/Interbase
var $substr = 'substr'; /// substring operator
var $length = 'length'; /// string length operator
@@ -231,7 +252,7 @@
var $false = '0'; /// string that represents FALSE for a database
var $replaceQuote = "\\'"; /// string to use to replace quotes
var $nameQuote = '"'; /// string to use to quote identifiers and names
- var $charSet=false; /// character set to use - only for interbase
+ var $charSet=false; /// character set to use - only for interbase, postgres and oci8
var $metaDatabasesSQL = '';
var $metaTablesSQL = '';
var $uniqueOrderBy = false; /// All order by columns have to be unique
@@ -322,6 +343,11 @@
return array('description' => '', 'version' => '');
}
+ function IsConnected()
+ {
+ return !empty($this->_connectionID);
+ }
+
function _findvers($str)
{
if (preg_match('/([0-9]+\.([0-9\.])+)/',$str, $arr)) return $arr[1];
@@ -346,7 +372,7 @@
return;
}
- if ($newline) $msg .= " \n";
+ if ($newline) $msg .= " \n";
if (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']) || !$newline) echo $msg;
else echo strip_tags($msg);
@@ -388,11 +414,13 @@
} else {
if ($this->_connect($this->host, $this->user, $this->password, $this->database)) return true;
}
+
$err = $this->ErrorMsg();
if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'";
if ($fn = $this->raiseErrorFn)
$fn($this->databaseType,'CONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this);
+ $this->_connectionID = false;
if ($this->debug) ADOConnection::outp( $this->host.': '.$err);
return false;
}
@@ -448,6 +476,7 @@
$fn($this->databaseType,'PCONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this);
}
+ $this->_connectionID = false;
if ($this->debug) ADOConnection::outp( $this->host.': '.$err);
return false;
}
@@ -478,7 +507,7 @@
{
return $sql;
}
-
+
/**
* Some databases, eg. mssql require a different function for preparing
* stored procedures. So we cannot use Prepare().
@@ -665,8 +694,8 @@
Advantages include:
a. StartTrans/CompleteTrans is nestable, unlike BeginTrans/CommitTrans/RollbackTrans.
- Only the outermost block is treated as a transaction.
- b. CompleteTrans auto-detects SQL errors, and will rollback on errors, commit otherwise.
+ Only the outermost block is treated as a transaction.
+ b. CompleteTrans auto-detects SQL errors, and will rollback on errors, commit otherwise.
c. All BeginTrans/CommitTrans/RollbackTrans inside a StartTrans/CompleteTrans block
are disabled, making it backward compatible.
*/
@@ -771,20 +800,24 @@
$sql = ''; $i = 0;
foreach($arr as $v) {
$sql .= $sqlarr[$i];
- // from Ron Baldwin
+ // from Ron Baldwin
// Only quote string types
- if (gettype($v) == 'string')
+ $typ = gettype($v);
+ if ($typ == 'string')
$sql .= $this->qstr($v);
+ else if ($typ == 'double')
+ $sql .= str_replace(',','.',$v); // locales fix so 1.1 does not get converted to 1,1
else if ($v === null)
$sql .= 'NULL';
else
$sql .= $v;
$i += 1;
}
- $sql .= $sqlarr[$i];
-
- if ($i+1 != sizeof($sqlarr))
- ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql));
+ if (isset($sqlarr[$i])) {
+ $sql .= $sqlarr[$i];
+ if ($i+1 != sizeof($sqlarr)) ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql));
+ } else if ($i != sizeof($sqlarr))
+ ADOConnection::outp( "Input array does not match ?: ".htmlspecialchars($sql));
$ret =& $this->_Execute($sql);
if (!$ret) return $ret;
@@ -808,7 +841,7 @@
}
- function& _Execute($sql,$inputarr=false)
+ function &_Execute($sql,$inputarr=false)
{
if ($this->debug) {
@@ -829,8 +862,8 @@
if ($fn) {
$fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr,$this);
}
-
- return false;
+ $false = false;
+ return $false;
}
if ($this->_queryID === true) { // return simplified recordset for inserts/updates/deletes with lower overhead
@@ -864,7 +897,7 @@
return $this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID));
}
- function DropSequence($seqname)
+ function DropSequence($seqname='adodbseq')
{
if (empty($this->_dropSeqSQL)) return false;
return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
@@ -887,7 +920,7 @@
$getnext = sprintf($this->_genIDSQL,$seqname);
$holdtransOK = $this->_transOK;
- $rs = @$this->Execute($getnext);
+ @($rs = $this->Execute($getnext));
if (!$rs) {
$this->_transOK = $holdtransOK; //if the status was ok before reset
$createseq = $this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID));
@@ -902,12 +935,14 @@
}
/**
+ * @param $table string name of the table, not needed by all databases (eg. mysql), default ''
+ * @param $column string name of the column, not needed by all databases (eg. mysql), default ''
* @return the last inserted ID. Not all databases support this.
*/
- function Insert_ID()
+ function Insert_ID($table='',$column='')
{
if ($this->_logsql && $this->lastInsID) return $this->lastInsID;
- if ($this->hasInsertID) return $this->_insertid();
+ if ($this->hasInsertID) return $this->_insertid($table,$column);
if ($this->debug) {
ADOConnection::outp( 'Insert_ID error
');
adodb_backtrace();
@@ -917,7 +952,7 @@
/**
- * Portable Insert ID. Pablo Roca
+ * Portable Insert ID. Pablo Roca
*
* @return the last inserted ID. All databases support this. But aware possible
* problems in multiuser environments. Heavy test this before deploying.
@@ -925,7 +960,7 @@
function PO_Insert_ID($table="", $id="")
{
if ($this->hasInsertID){
- return $this->Insert_ID();
+ return $this->Insert_ID($table,$id);
} else {
return $this->GetOne("SELECT MAX($id) FROM $table");
}
@@ -1124,8 +1159,10 @@
*/
function &_rs2rs(&$rs,$nrows=-1,$offset=-1,$close=true)
{
- if (! $rs) return false;
-
+ if (! $rs) {
+ $false = false;
+ return $false;
+ }
$dbtype = $rs->databaseType;
if (!$dbtype) {
$rs = &$rs; // required to prevent crashing in 4.2.1, but does not happen in 4.3.1 -- why ?
@@ -1152,6 +1189,7 @@
$rs2->sql = $rs->sql;
$rs2->dataProvider = $this->dataProvider;
$rs2->InitArrayFields($arr,$flds);
+ $rs2->fetchMode = isset($rs->adodbFetchMode) ? $rs->adodbFetchMode : $rs->fetchMode;
return $rs2;
}
@@ -1167,8 +1205,10 @@
function &GetAssoc($sql, $inputarr=false,$force_array = false, $first2cols = false)
{
$rs =& $this->Execute($sql, $inputarr);
- if (!$rs) return false;
-
+ if (!$rs) {
+ $false = false;
+ return $false;
+ }
$arr =& $rs->GetAssoc($force_array,$first2cols);
return $arr;
}
@@ -1180,8 +1220,10 @@
$force_array = $inputarr;
}
$rs =& $this->CacheExecute($secs2cache, $sql, $inputarr);
- if (!$rs) return false;
-
+ if (!$rs) {
+ $false = false;
+ return $false;
+ }
$arr =& $rs->GetAssoc($force_array,$first2cols);
return $arr;
}
@@ -1293,7 +1335,10 @@
$ADODB_COUNTRECS = $savec;
if (!$rs)
if (defined('ADODB_PEAR')) return ADODB_PEAR_Error();
- else return false;
+ else {
+ $false = false;
+ return $false;
+ }
$arr =& $rs->GetArray();
$rs->Close();
return $arr;
@@ -1315,8 +1360,10 @@
if (!$rs)
if (defined('ADODB_PEAR')) return ADODB_PEAR_Error();
- else return false;
-
+ else {
+ $false = false;
+ return $false;
+ }
$arr =& $rs->GetArray();
$rs->Close();
return $arr;
@@ -1346,7 +1393,8 @@
return $arr;
}
- return false;
+ $false = false;
+ return $false;
}
function &CacheGetRow($secs2cache,$sql=false,$inputarr=false)
@@ -1358,7 +1406,8 @@
$rs->Close();
return $arr;
}
- return false;
+ $false = false;
+ return $false;
}
/**
@@ -1434,11 +1483,12 @@
if (strncmp(PHP_OS,'WIN',3) === 0) {
$cmd = 'del /s '.str_replace('/','\\',$ADODB_CACHE_DIR).'\adodb_*.cache';
} else {
- $cmd = 'rm -rf '.$ADODB_CACHE_DIR.'/??/adodb_*.cache';
+ //$cmd = 'find "'.$ADODB_CACHE_DIR.'" -type f -maxdepth 1 -print0 | xargs -0 rm -f';
+ $cmd = 'rm -rf '.$ADODB_CACHE_DIR.'/[0-9a-f][0-9a-f]/';
// old version 'rm -f `find '.$ADODB_CACHE_DIR.' -name adodb_*.cache`';
}
if ($this->debug) {
- ADOConnection::outp( "CacheFlush: $cmd\n", system($cmd)," ");
+ ADOConnection::outp( "CacheFlush: $cmd\n", system($cmd)," ");
} else {
exec($cmd);
}
@@ -1520,7 +1570,7 @@
$err = '';
if ($secs2cache > 0){
- $rs = &csv2rs($md5file,$err,$secs2cache);
+ $rs = &csv2rs($md5file,$err,$secs2cache,$this->arrayClass);
$this->numCacheHits += 1;
} else {
$err='Timeout 1';
@@ -1535,7 +1585,9 @@
}
if ($this->debug !== -1) ADOConnection::outp( " $md5file cache failure: $err (see sql below)");
}
+
$rs = &$this->Execute($sql,$inputarr);
+
if ($rs) {
$eof = $rs->EOF;
$rs = &$this->_rs2rs($rs); // read entire recordset into memory immediately
@@ -1580,6 +1632,45 @@
}
+ /*
+ Similar to PEAR DB's autoExecute(), except that
+ $mode can be 'INSERT' or 'UPDATE' or DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE
+ If $mode == 'UPDATE', then $where is compulsory as a safety measure.
+
+ $forceUpdate means that even if the data has not changed, perform update.
+ */
+ function AutoExecute($table, $fields_values, $mode = 'INSERT', $where = FALSE, $forceUpdate=true, $magicq=false)
+ {
+ //$flds = array_keys($fields_values);
+ //$fldstr = implode(', ',$flds);
+ $sql = 'SELECT * FROM '.$table;
+ if ($where!==FALSE) $sql .= ' WHERE '.$where;
+ else if ($mode == 'UPDATE') {
+ ADOConnection::outp('AutoExecute: Illegal mode=UPDATE with empty WHERE clause');
+ return false;
+ }
+
+ $rs =& $this->SelectLimit($sql,1);
+ if (!$rs) return false; // table does not exist
+
+ switch((string) $mode) {
+ case 'UPDATE':
+ case '2':
+ $sql = $this->GetUpdateSQL($rs, $fields_values, $forceUpdate, $magicq);
+ break;
+ case 'INSERT':
+ case '1':
+ $sql = $this->GetInsertSQL($rs, $fields_values, $magicq);
+ break;
+ default:
+ ADOConnection::outp("AutoExecute: Unknown mode=$mode");
+ return false;
+ }
+ if ($sql) return $this->Execute($sql);
+ return false;
+ }
+
+
/**
* Generates an Update Query based on an existing recordset.
* $arrFields is an associative array of fields with the value
@@ -1591,16 +1682,25 @@
*
* "Jonathan Younger"
*/
- function GetUpdateSQL(&$rs, $arrFields,$forceUpdate=false,$magicq=false,$forcenulls=null)
+ function GetUpdateSQL(&$rs, $arrFields,$forceUpdate=false,$magicq=false,$force=null)
{
global $ADODB_INCLUDED_LIB;
- if (!isset($forcenulls)) {
- $forcenulls = defined('ADODB_FORCE_NULLS') ? true : false;
+
+ //********************************************************//
+ //This is here to maintain compatibility
+ //with older adodb versions. Sets force type to force nulls if $forcenulls is set.
+ if (!isset($force)) {
+ global $ADODB_FORCE_TYPE;
+ $force = $ADODB_FORCE_TYPE;
}
+ //********************************************************//
+
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
- return _adodb_getupdatesql($this,$rs,$arrFields,$forceUpdate,$magicq,$forcenulls);
+ return _adodb_getupdatesql($this,$rs,$arrFields,$forceUpdate,$magicq,$force);
}
+
+
/**
* Generates an Insert Query based on an existing recordset.
@@ -1610,14 +1710,16 @@
* Note: This function should only be used on a recordset
* that is run against a single table.
*/
- function GetInsertSQL(&$rs, $arrFields,$magicq=false,$forcenulls=null)
+ function GetInsertSQL(&$rs, $arrFields,$magicq=false,$force=null)
{
global $ADODB_INCLUDED_LIB;
- if (!isset($forcenulls)) {
- $forcenulls = defined('ADODB_FORCE_NULLS') ? true : false;
+ if (!isset($force)) {
+ global $ADODB_FORCE_TYPE;
+ $force = $ADODB_FORCE_TYPE;
+
}
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
- return _adodb_getinsertsql($this,$rs,$arrFields,$magicq,$forcenulls);
+ return _adodb_getinsertsql($this,$rs,$arrFields,$magicq,$force);
}
@@ -1723,22 +1825,32 @@
$this->locale = $locale;
switch ($locale)
{
- default:
case 'En':
- $this->fmtDate="Y-m-d";
- $this->fmtTimeStamp = "Y-m-d H:i:s";
+ $this->fmtDate="'Y-m-d'";
+ $this->fmtTimeStamp = "'Y-m-d H:i:s'";
break;
-
+
+ case 'Us':
+ $this->fmtDate = "'m-d-Y'";
+ $this->fmtTimeStamp = "'m-d-Y H:i:s'";
+ break;
+
+ case 'Nl':
case 'Fr':
case 'Ro':
case 'It':
- $this->fmtDate="d-m-Y";
- $this->fmtTimeStamp = "d-m-Y H:i:s";
+ $this->fmtDate="'d-m-Y'";
+ $this->fmtTimeStamp = "'d-m-Y H:i:s'";
break;
case 'Ge':
- $this->fmtDate="d.m.Y";
- $this->fmtTimeStamp = "d.m.Y H:i:s";
+ $this->fmtDate="'d.m.Y'";
+ $this->fmtTimeStamp = "'d.m.Y H:i:s'";
+ break;
+
+ default:
+ $this->fmtDate="'Y-m-d'";
+ $this->fmtTimeStamp = "'Y-m-d H:i:s'";
break;
}
}
@@ -1747,14 +1859,11 @@
/**
* Close Connection
*/
- function Close()
+ function Close()
{
- return $this->_close();
-
- // "Simon Lee" reports that persistent connections need
- // to be closed too!
- //if ($this->_isPersistentConnection != true) return $this->_close();
- //else return true;
+ $rez = $this->_close();
+ $this->_connectionID = false;
+ return $rez;
}
/**
@@ -1825,8 +1934,11 @@
{
global $ADODB_FETCH_MODE;
- if ($mask) return false;
+ $false = false;
+ if ($mask) {
+ return $false;
+ }
if ($this->metaTablesSQL) {
// complicated state saving by the need for backward compat
$save = $ADODB_FETCH_MODE;
@@ -1838,7 +1950,7 @@
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
- if ($rs === false) return false;
+ if ($rs === false) return $false;
$arr =& $rs->GetArray();
$arr2 = array();
@@ -1859,7 +1971,7 @@
$rs->Close();
return $arr2;
}
- return false;
+ return $false;
}
@@ -1885,6 +1997,8 @@
{
global $ADODB_FETCH_MODE;
+ $false = false;
+
if (!empty($this->metaColumnsSQL)) {
$schema = false;
@@ -1896,7 +2010,7 @@
$rs = $this->Execute(sprintf($this->metaColumnsSQL,($upper)?strtoupper($table):$table));
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
- if ($rs === false) return false;
+ if ($rs === false || $rs->EOF) return $false;
$retarr = array();
while (!$rs->EOF) { //print_r($rs->fields);
@@ -1917,19 +2031,31 @@
$rs->Close();
return $retarr;
}
- return false;
+ return $false;
}
/**
* List indexes on a table as an array.
- * @param table table name to query
- * @param primary include primary keys.
+ * @param table table name to query
+ * @param primary true to only show primary keys. Not actually used for most databases
*
- * @return array of indexes on current table.
+ * @return array of indexes on current table. Each element represents an index, and is itself an associative array.
+
+ Array (
+ [name_of_index] => Array
+ (
+ [unique] => true or false
+ [columns] => Array
+ (
+ [0] => firstname
+ [1] => lastname
+ )
+ )
*/
function &MetaIndexes($table, $primary = false, $owner = false)
{
- return FALSE;
+ $false = false;
+ return false;
}
/**
@@ -1941,8 +2067,10 @@
function &MetaColumnNames($table, $numIndexes=false)
{
$objarr =& $this->MetaColumns($table);
- if (!is_array($objarr)) return false;
-
+ if (!is_array($objarr)) {
+ $false = false;
+ return $false;
+ }
$arr = array();
if ($numIndexes) {
$i = 0;
@@ -2021,6 +2149,12 @@
*/
function UnixDate($v)
{
+ if (is_object($v)) {
+ // odbtp support
+ //( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 )
+ return adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year);
+ }
+
if (is_numeric($v) && strlen($v) !== 8) return $v;
if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|",
($v), $rr)) return false;
@@ -2039,6 +2173,12 @@
*/
function UnixTimeStamp($v)
{
+ if (is_object($v)) {
+ // odbtp support
+ //( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 )
+ return adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year);
+ }
+
if (!preg_match(
"|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|",
($v), $rr)) return false;
@@ -2478,7 +2618,8 @@
$cols = $this->_numOfFields;
if ($cols < 2) {
- return false;
+ $false = false;
+ return $false;
}
$numIndex = isset($this->fields[0]);
$results = array();
@@ -2592,14 +2733,7 @@
*/
function UnixDate($v)
{
- if (is_numeric($v) && strlen($v) !== 8) return $v;
- if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|",
- ($v), $rr)) return false;
-
- if ($rr[1] <= TIMESTAMP_FIRST_YEAR || $rr[1] > 10000) return 0;
-
- // h-m-s-MM-DD-YY
- return @adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
+ return ADOConnection::UnixDate($v);
}
@@ -2610,15 +2744,7 @@
*/
function UnixTimeStamp($v)
{
-
- if (!preg_match(
- "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|",
- ($v), $rr)) return false;
- if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0;
-
- // h-m-s-MM-DD-YY
- if (!isset($rr[5])) return adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
- return @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]);
+ return ADOConnection::UnixTimeStamp($v);
}
@@ -2656,7 +2782,10 @@
*/
function &FetchRow()
{
- if ($this->EOF) return false;
+ if ($this->EOF) {
+ $false = false;
+ return $false;
+ }
$arr = $this->fields;
$this->_currentRow++;
if (!$this->_fetch()) $this->EOF = true;
@@ -2970,7 +3099,9 @@
}
}
$i = 0;
- $o = &$this->_obj;
+ if (PHP_VERSION >= 5) $o = clone($this->_obj);
+ else $o = $this->_obj;
+
for ($i=0; $i <$this->_numOfFields; $i++) {
$name = $this->_names[$i];
if ($isupper) $n = strtoupper($name);
@@ -2992,7 +3123,7 @@
*/
function &FetchNextObj()
{
- $o = $this->FetchNextObject(false);
+ $o =& $this->FetchNextObject(false);
return $o;
}
@@ -3102,6 +3233,9 @@
'INT IDENTITY' => 'R',
##
'INT' => 'I',
+ 'INT2' => 'I',
+ 'INT4' => 'I',
+ 'INT8' => 'I',
'INTEGER' => 'I',
'INTEGER UNSIGNED' => 'I',
'SHORT' => 'I',
@@ -3142,7 +3276,7 @@
$tmap = false;
$t = strtoupper($t);
- $tmap = @$typeMap[$t];
+ $tmap = (isset($typeMap[$t])) ? $typeMap[$t] : 'N';
switch ($tmap) {
case 'C':
@@ -3317,7 +3451,8 @@
/* Use associative array to get fields array */
function Fields($colname)
{
- if ($this->fetchMode & ADODB_FETCH_ASSOC) {
+ $mode = isset($this->adodbFetchMode) ? $this->adodbFetchMode : $this->fetchMode;
+ if ($mode & ADODB_FETCH_ASSOC) {
if (!isset($this->fields[$colname])) $colname = strtolower($colname);
return $this->fields[$colname];
}
@@ -3419,19 +3554,26 @@
if (!$dbType) return false;
$db = strtolower($dbType);
switch ($db) {
+ case 'ado':
+ if (PHP_VERSION >= 5) $db = 'ado5';
+ $class = 'ado';
+ break;
case 'ifx':
- case 'maxsql': $db = 'mysqlt'; break;
+ case 'maxsql': $class = $db = 'mysqlt'; break;
case 'postgres':
- case 'pgsql': $db = 'postgres7'; break;
+ case 'postgres8':
+ case 'pgsql': $class = $db = 'postgres7'; break;
+ default:
+ $class = $db; break;
}
- @include_once(ADODB_DIR."/drivers/adodb-".$db.".inc.php");
- $ADODB_LASTDB = $db;
- $ok = class_exists("ADODB_" . $db);
- if ($ok) return $db;
-
- print_r(get_declared_classes());
$file = ADODB_DIR."/drivers/adodb-".$db.".inc.php";
+ @include_once($file);
+ $ADODB_LASTDB = $class;
+
+ if (class_exists("ADODB_" . $db)) return $class;
+
+ //ADOConnection::outp(adodb_pr(get_declared_classes(),true));
if (!file_exists($file)) ADOConnection::outp("Missing file: $file");
else ADOConnection::outp("Syntax error in file: $file");
return false;
@@ -3460,7 +3602,7 @@
if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2);
$errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false;
-
+ $false = false;
if (strpos($db,'://')) {
$origdsn = $db;
$dsna = @parse_url($db);
@@ -3468,11 +3610,11 @@
// special handling of oracle, which might not have host
$db = str_replace('@/','@adodb-fakehost/',$db);
$dsna = parse_url($db);
- if (!$dsna) return false;
+ if (!$dsna) return $false;
$dsna['host'] = '';
}
$db = @$dsna['scheme'];
- if (!$db) return false;
+ if (!$db) return $false;
$dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : '';
$dsna['user'] = isset($dsna['user']) ? rawurldecode($dsna['user']) : '';
$dsna['pass'] = isset($dsna['pass']) ? rawurldecode($dsna['pass']) : '';
@@ -3517,13 +3659,13 @@
} else
ADOConnection::outp( "ADONewConnection: Unable to load database driver '$db'
",false);
- return false;
+ return $false;
}
$cls = 'ADODB_'.$db;
if (!class_exists($cls)) {
adodb_backtrace();
- return false;
+ return $false;
}
$obj =& new $cls();
@@ -3551,6 +3693,8 @@
#mysqli
case 'port': $obj->port = $v; break;
case 'socket': $obj->socket = $v; break;
+ #oci8
+ case 'nls_date_format': $obj->NLS_DATE_FORMAT = $v; break;
}
}
if (empty($persist))
@@ -3558,7 +3702,7 @@
else
$ok = $obj->PConnect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']);
- if (!$ok) return false;
+ if (!$ok) return $false;
}
}
return $obj;
@@ -3569,53 +3713,53 @@
// $perf == true means called by NewPerfMonitor()
function _adodb_getdriver($provider,$drivername,$perf=false)
{
- if ($provider !== 'native' && $provider != 'odbc' && $provider != 'ado')
- $drivername = $provider;
- else {
- if (substr($drivername,0,5) == 'odbc_') $drivername = substr($drivername,5);
- else if (substr($drivername,0,4) == 'ado_') $drivername = substr($drivername,4);
- else
- switch($drivername) {
- case 'oracle': $drivername = 'oci8';break;
- //case 'sybase': $drivername = 'mssql';break;
- case 'access':
- if ($perf) $drivername = '';
- break;
- case 'db2':
- break;
- default:
- $drivername = 'generic';
- break;
- }
+ switch ($provider) {
+ case 'odbtp': if (strncmp('odbtp_',$drivername,6)==0) return substr($drivername,6);
+ case 'odbc' : if (strncmp('odbc_',$drivername,5)==0) return substr($drivername,5);
+ case 'ado' : if (strncmp('ado_',$drivername,4)==0) return substr($drivername,4);
+ case 'native': break;
+ default:
+ return $provider;
}
+ switch($drivername) {
+ case 'oracle': $drivername = 'oci8'; break;
+ case 'access': if ($perf) $drivername = ''; break;
+ case 'db2' : break;
+ case 'sapdb' : break;
+ default:
+ $drivername = 'generic';
+ break;
+ }
return $drivername;
}
function &NewPerfMonitor(&$conn)
{
+ $false = false;
$drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType,true);
- if (!$drivername || $drivername == 'generic') return false;
+ if (!$drivername || $drivername == 'generic') return $false;
include_once(ADODB_DIR.'/adodb-perf.inc.php');
@include_once(ADODB_DIR."/perf/perf-$drivername.inc.php");
$class = "Perf_$drivername";
- if (!class_exists($class)) return false;
+ if (!class_exists($class)) return $false;
$perf =& new $class($conn);
return $perf;
}
- function &NewDataDictionary(&$conn)
+ function &NewDataDictionary(&$conn,$drivername=false)
{
- $drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType);
-
+ $false = false;
+ if (!$drivername) $drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType);
+
include_once(ADODB_DIR.'/adodb-lib.inc.php');
include_once(ADODB_DIR.'/adodb-datadict.inc.php');
$path = ADODB_DIR."/datadict/datadict-$drivername.inc.php";
if (!file_exists($path)) {
ADOConnection::outp("Database driver '$path' not available");
- return false;
+ return $false;
}
include_once($path);
$class = "ADODB2_$drivername";
@@ -3635,12 +3779,20 @@
/*
Perform a print_r, with pre tags for better formatting.
*/
- function adodb_pr($var)
+ function adodb_pr($var,$as_string=false)
{
+ if ($as_string) ob_start();
+
if (isset($_SERVER['HTTP_USER_AGENT'])) {
echo " \n";print_r($var);echo " \n";
} else
print_r($var);
+
+ if ($as_string) {
+ $s = ob_get_contents();
+ ob_end_clean();
+ return $s;
+ }
}
/*
diff --git a/lib/adodb/datadict/datadict-access.inc.php b/lib/adodb/datadict/datadict-access.inc.php
index 1ab7b123766..b473226023e 100644
--- a/lib/adodb/datadict/datadict-access.inc.php
+++ b/lib/adodb/datadict/datadict-access.inc.php
@@ -1,7 +1,7 @@
MetaColumns($tablename);
+ if ( empty($cols)) {
+ return $this->CreateTableSQL($tablename, $flds, $tableoptions);
+ }
+
+ // already exists, alter table instead
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $alter = 'ALTER TABLE ' . $this->TableName($tablename);
+ $sql = array();
+
+ foreach ( $lines as $id => $v ) {
+ if ( isset($cols[$id]) && is_object($cols[$id]) ) {
+ /**
+ If the first field of $v is the fieldname, and
+ the second is the field type/size, we assume its an
+ attempt to modify the column size, so check that it is allowed
+ $v can have an indeterminate number of blanks between the
+ fields, so account for that too
+ */
+ $vargs = explode(' ' , $v);
+ // assume that $vargs[0] is the field name.
+ $i=0;
+ // Find the next non-blank value;
+ for ($i=1;$ialterCol . ' ' . $v;
+ } else {
+ $sql[] = $alter . $this->addCol . ' ' . $v;
+ }
+ }
+
+ return $sql;
+ }
+
}
diff --git a/lib/adodb/datadict/datadict-firebird.inc.php b/lib/adodb/datadict/datadict-firebird.inc.php
index e27b0dfab9c..7028a8bc39e 100644
--- a/lib/adodb/datadict/datadict-firebird.inc.php
+++ b/lib/adodb/datadict/datadict-firebird.inc.php
@@ -1,7 +1,7 @@
dropCol $v";
+ $f[] = "\n$this->dropCol ".$this->NameQuote($v);
}
- $s .= implode(',',$f);
+ $s .= implode(', ',$f);
$sql[] = $s;
return $sql;
}
@@ -239,12 +243,9 @@ CREATE TABLE
case 'BIGINT':
return $ftype;
}
- if (strlen($fsize) && $ty != 'X' && $ty != 'B' && strpos($ftype,'(') === false) {
- $ftype .= "(".$fsize;
- if (strlen($fprec)) $ftype .= ",".$fprec;
- $ftype .= ')';
- }
- return $ftype;
+ if ($ty == 'T') return $ftype;
+ return parent::_GetSize($ftype, $ty, $fsize, $fprec);
+
}
}
?>
\ No newline at end of file
diff --git a/lib/adodb/datadict/datadict-mysql.inc.php b/lib/adodb/datadict/datadict-mysql.inc.php
index bee8f7c464d..8521f7dcc16 100644
--- a/lib/adodb/datadict/datadict-mysql.inc.php
+++ b/lib/adodb/datadict/datadict-mysql.inc.php
@@ -1,7 +1,7 @@
type;
$len = $fieldobj->max_length;
}
+ $is_serial = is_object($fieldobj) && $fieldobj->primary_key && $fieldobj->auto_increment;
$len = -1; // mysql max_length is not accurate
switch (strtoupper($t)) {
@@ -65,11 +67,11 @@ class ADODB2_mysql extends ADODB_DataDict {
return 'F';
case 'INT':
- case 'INTEGER': return (!empty($fieldobj->primary_key)) ? 'R' : 'I';
- case 'TINYINT': return (!empty($fieldobj->primary_key)) ? 'R' : 'I1';
- case 'SMALLINT': return (!empty($fieldobj->primary_key)) ? 'R' : 'I2';
- case 'MEDIUMINT': return (!empty($fieldobj->primary_key)) ? 'R' : 'I4';
- case 'BIGINT': return (!empty($fieldobj->primary_key)) ? 'R' : 'I8';
+ case 'INTEGER': return $is_serial ? 'R' : 'I';
+ case 'TINYINT': return $is_serial ? 'R' : 'I1';
+ case 'SMALLINT': return $is_serial ? 'R' : 'I2';
+ case 'MEDIUMINT': return $is_serial ? 'R' : 'I4';
+ case 'BIGINT': return $is_serial ? 'R' : 'I8';
default: return 'N';
}
}
@@ -91,10 +93,10 @@ class ADODB2_mysql extends ADODB_DataDict {
case 'L': return 'TINYINT';
case 'R':
+ case 'I4':
case 'I': return 'INTEGER';
case 'I1': return 'TINYINT';
case 'I2': return 'SMALLINT';
- case 'I4': return 'MEDIUMINT';
case 'I8': return 'BIGINT';
case 'F': return 'DOUBLE';
diff --git a/lib/adodb/datadict/datadict-oci8.inc.php b/lib/adodb/datadict/datadict-oci8.inc.php
index 3c9d6694125..de6f7331d89 100644
--- a/lib/adodb/datadict/datadict-oci8.inc.php
+++ b/lib/adodb/datadict/datadict-oci8.inc.php
@@ -1,7 +1,7 @@
$v) $flds[$k] = $this->NameQuote($v);
+
$sql = array();
$s = "ALTER TABLE $tabname DROP(";
- $s .= implode(',',$flds).') CASCADE COSTRAINTS';
+ $s .= implode(', ',$flds).') CASCADE CONSTRAINTS';
$sql[] = $s;
return $sql;
}
diff --git a/lib/adodb/datadict/datadict-postgres.inc.php b/lib/adodb/datadict/datadict-postgres.inc.php
index 525fa83f501..c25123e1beb 100644
--- a/lib/adodb/datadict/datadict-postgres.inc.php
+++ b/lib/adodb/datadict/datadict-postgres.inc.php
@@ -1,7 +1,7 @@
type;
$len = $fieldobj->max_length;
}
+ $is_serial = is_object($fieldobj) && $fieldobj->primary_key && $fieldobj->unique &&
+ $fieldobj->has_default && substr($fieldobj->default_value,0,8) == 'nextval(';
+
switch (strtoupper($t)) {
case 'INTERVAL':
case 'CHAR':
@@ -60,12 +64,12 @@ class ADODB2_postgres extends ADODB_DataDict {
case 'TIMESTAMPTZ':
return 'T';
- case 'INTEGER': return (empty($fieldobj->primary_key) && empty($fieldobj->unique))? 'I' : 'R';
+ case 'INTEGER': return !$is_serial ? 'I' : 'R';
case 'SMALLINT':
- case 'INT2': return (empty($fieldobj->primary_key) && empty($fieldobj->unique))? 'I2' : 'R';
- case 'INT4': return (empty($fieldobj->primary_key) && empty($fieldobj->unique))? 'I4' : 'R';
+ case 'INT2': return !$is_serial ? 'I2' : 'R';
+ case 'INT4': return !$is_serial ? 'I4' : 'R';
case 'BIGINT':
- case 'INT8': return (empty($fieldobj->primary_key) && empty($fieldobj->unique))? 'I8' : 'R';
+ case 'INT8': return !$is_serial ? 'I8' : 'R';
case 'OID':
case 'SERIAL':
@@ -111,23 +115,150 @@ class ADODB2_postgres extends ADODB_DataDict {
}
}
- /* The following does not work in Pg 6.0 - does anyone want to contribute code?
-
- //"ALTER TABLE table ALTER COLUMN column SET DEFAULT mydef" and
- //"ALTER TABLE table ALTER COLUMN column DROP DEFAULT mydef"
- //"ALTER TABLE table ALTER COLUMN column SET NOT NULL" and
- //"ALTER TABLE table ALTER COLUMN column DROP NOT NULL"*/
- function AlterColumnSQL($tabname, $flds)
+ /**
+ * Adding a new Column
+ *
+ * reimplementation of the default function as postgres does NOT allow to set the default in the same statement
+ *
+ * @param string $tabname table-name
+ * @param string $flds column-names and types for the changed columns
+ * @return array with SQL strings
+ */
+ function AddColumnSQL($tabname, $flds)
{
- if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported for PostgreSQL");
- return array();
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' ';
+ foreach($lines as $v) {
+ if (($not_null = preg_match('/NOT NULL/i',$v))) {
+ $v = preg_replace('/NOT NULL/i','',$v);
+ }
+ if (preg_match('/^([^ ]+) .*(DEFAULT [^ ]+)/',$v,$matches)) {
+ list(,$colname,$default) = $matches;
+ $sql[] = $alter . str_replace($default,'',$v);
+ $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET ' . $default;
+ } else {
+ $sql[] = $alter . $v;
+ }
+ if ($not_null) {
+ list($colname) = explode(' ',$v);
+ $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET NOT NULL';
+ }
+ }
+ return $sql;
}
-
- function DropColumnSQL($tabname, $flds)
+ /**
+ * Change the definition of one column
+ *
+ * Postgres can't do that on it's own, you need to supply the complete defintion of the new table,
+ * to allow, recreating the table and copying the content over to the new table
+ * @param string $tabname table-name
+ * @param string $flds column-name and type for the changed column
+ * @param string $tableflds complete defintion of the new table, eg. for postgres, default ''
+ * @param array/ $tableoptions options for the new table see CreateTableSQL, default ''
+ * @return array with SQL strings
+ */
+ function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{
- if ($this->debug) ADOConnection::outp("DropColumnSQL only works with PostgreSQL 7.3+");
- return ADODB_DataDict::DropColumnSQL($tabname, $flds)."/* only works for PostgreSQL 7.3+ */";
+ if (!$tableflds) {
+ if ($this->debug) ADOConnection::outp("AlterColumnSQL needs a complete table-definiton for PostgreSQL");
+ return array();
+ }
+ return $this->_recreate_copy_table($tabname,False,$tableflds,$tableoptions);
+ }
+
+ /**
+ * Drop one column
+ *
+ * Postgres < 7.3 can't do that on it's own, you need to supply the complete defintion of the new table,
+ * to allow, recreating the table and copying the content over to the new table
+ * @param string $tabname table-name
+ * @param string $flds column-name and type for the changed column
+ * @param string $tableflds complete defintion of the new table, eg. for postgres, default ''
+ * @param array/ $tableoptions options for the new table see CreateTableSQL, default ''
+ * @return array with SQL strings
+ */
+ function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ $has_drop_column = 7.3 <= (float) @$this->serverInfo['version'];
+ if (!$has_drop_column && !$tableflds) {
+ if ($this->debug) ADOConnection::outp("DropColumnSQL needs complete table-definiton for PostgreSQL < 7.3");
+ return array();
+ }
+ if ($has_drop_column) {
+ return ADODB_DataDict::DropColumnSQL($tabname, $flds);
+ }
+ return $this->_recreate_copy_table($tabname,$flds,$tableflds,$tableoptions);
+ }
+
+ /**
+ * Save the content into a temp. table, drop and recreate the original table and copy the content back in
+ *
+ * We also take care to set the values of the sequenz and recreate the indexes.
+ * All this is done in a transaction, to not loose the content of the table, if something went wrong!
+ * @internal
+ * @param string $tabname table-name
+ * @param string $dropflds column-names to drop
+ * @param string $tableflds complete defintion of the new table, eg. for postgres
+ * @param array/string $tableoptions options for the new table see CreateTableSQL, default ''
+ * @return array with SQL strings
+ */
+ function _recreate_copy_table($tabname,$dropflds,$tableflds,$tableoptions='')
+ {
+ if ($dropflds && !is_array($dropflds)) $dropflds = explode(',',$dropflds);
+ $copyflds = array();
+ foreach($this->MetaColumns($tabname) as $fld) {
+ if (!$dropflds || !in_array($fld->name,$dropflds)) {
+ // we need to explicit convert varchar to a number to be able to do an AlterColumn of a char column to a nummeric one
+ if (preg_match('/'.$fld->name.' (I|I2|I4|I8|N|F)/i',$tableflds,$matches) &&
+ in_array($fld->type,array('varchar','char','text','bytea'))) {
+ $copyflds[] = "to_number($fld->name,'S99D99')";
+ } else {
+ $copyflds[] = $fld->name;
+ }
+ // identify the sequence name and the fld its on
+ if ($fld->primary_key && $fld->has_default &&
+ preg_match("/nextval\('([^']+)'::text\)/",$fld->default_value,$matches)) {
+ $seq_name = $matches[1];
+ $seq_fld = $fld->name;
+ }
+ }
+ }
+ $copyflds = implode(', ',$copyflds);
+
+ $tempname = $tabname.'_tmp';
+ $aSql[] = 'BEGIN'; // we use a transaction, to make sure not to loose the content of the table
+ $aSql[] = "SELECT * INTO TEMPORARY TABLE $tempname FROM $tabname";
+ $aSql = array_merge($aSql,$this->DropTableSQL($tabname));
+ $aSql = array_merge($aSql,$this->CreateTableSQL($tabname,$tableflds,$tableoptions));
+ $aSql[] = "INSERT INTO $tabname SELECT $copyflds FROM $tempname";
+ if ($seq_name && $seq_fld) { // if we have a sequence we need to set it again
+ $seq_name = $tabname.'_'.$seq_fld.'_seq'; // has to be the name of the new implicit sequence
+ $aSql[] = "SELECT setval('$seq_name',MAX($seq_fld)) FROM $tabname";
+ }
+ $aSql[] = "DROP TABLE $tempname";
+ // recreate the indexes, if they not contain one of the droped columns
+ foreach($this->MetaIndexes($tabname) as $idx_name => $idx_data)
+ {
+ if (substr($idx_name,-5) != '_pkey' && (!$dropflds || !count(array_intersect($dropflds,$idx_data['columns'])))) {
+ $aSql = array_merge($aSql,$this->CreateIndexSQL($idx_name,$tabname,$idx_data['columns'],
+ $idx_data['unique'] ? array('UNIQUE') : False));
+ }
+ }
+ $aSql[] = 'COMMIT';
+ return $aSql;
+ }
+
+ function DropTableSQL($tabname)
+ {
+ $sql = ADODB_DataDict::DropTableSQL($tabname);
+
+ $drop_seq = $this->_DropAutoIncrement($tabname);
+ if ($drop_seq) $sql[] = $drop_seq;
+
+ return $sql;
}
// return string must begin with space
@@ -144,9 +275,20 @@ class ADODB2_postgres extends ADODB_DataDict {
return $suffix;
}
- function _DropAutoIncrement($t)
+ // search for a sequece for the given table (asumes the seqence-name contains the table-name!)
+ // if yes return sql to drop it
+ // this is still necessary if postgres < 7.3 or the SERIAL was created on an earlier version!!!
+ function _DropAutoIncrement($tabname)
{
- return "drop sequence ".$t."_m_id_seq";
+ $tabname = $this->connection->quote('%'.$tabname.'%');
+
+ $seq = $this->connection->GetOne("SELECT relname FROM pg_class WHERE NOT relname ~ 'pg_.*' AND relname LIKE $tabname AND relkind='S'");
+
+ // check if a tables depends on the sequenz and it therefor cant and dont need to be droped separatly
+ if (!$seq || $this->connection->GetOne("SELECT relname FROM pg_class JOIN pg_depend ON pg_class.relfilenode=pg_depend.objid WHERE relname='$seq' AND relkind='S' AND deptype='i'")) {
+ return False;
+ }
+ return "DROP SEQUENCE ".$seq;
}
/*
diff --git a/lib/adodb/datadict/datadict-sapdb.inc.php b/lib/adodb/datadict/datadict-sapdb.inc.php
new file mode 100644
index 00000000000..7f6b5ee048f
--- /dev/null
+++ b/lib/adodb/datadict/datadict-sapdb.inc.php
@@ -0,0 +1,121 @@
+type;
+ $len = $fieldobj->max_length;
+ }
+ static $maxdb_type2adodb = array(
+ 'VARCHAR' => 'C',
+ 'CHARACTER' => 'C',
+ 'LONG' => 'X', // no way to differ between 'X' and 'B' :-(
+ 'DATE' => 'D',
+ 'TIMESTAMP' => 'T',
+ 'BOOLEAN' => 'L',
+ 'INTEGER' => 'I4',
+ 'SMALLINT' => 'I2',
+ 'FLOAT' => 'F',
+ 'FIXED' => 'N',
+ );
+ $type = isset($maxdb_type2adodb[$t]) ? $maxdb_type2adodb[$t] : 'C';
+
+ // convert integer-types simulated with fixed back to integer
+ if ($t == 'FIXED' && !$fieldobj->scale && ($len == 20 || $len == 3)) {
+ $type = $len == 20 ? 'I8' : 'I1';
+ }
+ if ($fieldobj->auto_increment) $type = 'R';
+
+ return $type;
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
+ {
+ $suffix = '';
+ if ($funsigned) $suffix .= ' UNSIGNED';
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ if ($fautoinc) $suffix .= ' DEFAULT SERIAL';
+ elseif (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ function AddColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ return array( 'ALTER TABLE ' . $tabname . ' ADD (' . implode(', ',$lines) . ')' );
+ }
+
+ function AlterColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ return array( 'ALTER TABLE ' . $tabname . ' MODIFY (' . implode(', ',$lines) . ')' );
+ }
+
+ function DropColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ if (!is_array($flds)) $flds = explode(',',$flds);
+ foreach($flds as $k => $v) {
+ $flds[$k] = $this->NameQuote($v);
+ }
+ return array( 'ALTER TABLE ' . $tabname . ' DROP (' . implode(', ',$flds) . ')' );
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/lib/adodb/datadict/datadict-sybase.inc.php b/lib/adodb/datadict/datadict-sybase.inc.php
index 592d42b355d..53ea991c9b7 100644
--- a/lib/adodb/datadict/datadict-sybase.inc.php
+++ b/lib/adodb/datadict/datadict-sybase.inc.php
@@ -1,7 +1,7 @@
TableName ($tabname);
+ $tabname = $this->TableName($tabname);
if (!is_array($flds)) $flds = explode(',',$flds);
$f = array();
$s = "ALTER TABLE $tabname";
foreach($flds as $v) {
- $f[] = "\n$this->dropCol $v";
+ $f[] = "\n$this->dropCol ".$this->NameQuote($v);
}
- $s .= implode(',',$f);
+ $s .= implode(', ',$f);
$sql[] = $s;
return $sql;
}
diff --git a/lib/adodb/drivers/adodb-access.inc.php b/lib/adodb/drivers/adodb-access.inc.php
index 53a267853d2..d9be94d7289 100644
--- a/lib/adodb/drivers/adodb-access.inc.php
+++ b/lib/adodb/drivers/adodb-access.inc.php
@@ -1,6 +1,6 @@
debug) ADOConnection::outp( "Host=".$argHostname." \n version=$dbc->version");
+ if ($this->debug) ADOConnection::outp( "Host=".$argHostname." \n version=$dbc->version");
// @ added below for php 4.0.1 and earlier
@$dbc->Open((string) $argHostname);
@@ -160,7 +160,7 @@ class ADODB_ado extends ADOConnection {
$tt=substr($t->value,0,6);
if ($tt!='SYSTEM' && $tt !='ACCESS')
$arr[]=$f->value;
- //print $f->value . ' ' . $t->value.' ';
+ //print $f->value . ' ' . $t->value.' ';
$adors->MoveNext();
}
$adors->Close();
@@ -172,7 +172,7 @@ class ADODB_ado extends ADOConnection {
function &MetaColumns($table)
{
$table = strtoupper($table);
- $arr= array();
+ $arr = array();
$dbc = $this->_connectionID;
$adors=@$dbc->OpenSchema(4);//tables
@@ -196,8 +196,8 @@ class ADODB_ado extends ADOConnection {
}
$adors->Close();
}
-
- return $arr;
+ $false = false;
+ return empty($arr) ? $false : $arr;
}
@@ -208,6 +208,7 @@ class ADODB_ado extends ADOConnection {
{
$dbc = $this->_connectionID;
+ $false = false;
// return rs
if ($inputarr) {
@@ -230,21 +231,19 @@ class ADODB_ado extends ADOConnection {
$p = false;
$rs = $oCmd->Execute();
$e = $dbc->Errors;
- if ($dbc->Errors->Count > 0) return false;
+ if ($dbc->Errors->Count > 0) return $false;
return $rs;
}
$rs = @$dbc->Execute($sql,$this->_affectedRows, $this->_execute_option);
- /*
- $rs = new COM('ADODB.Recordset');
- if ($rs) {
- $rs->Open ($sql, $dbc, $this->_cursor_type,$this->_lock_type, $this->_execute_option);
- }
- */
- if ($dbc->Errors->Count > 0) return false;
- if (! $rs) return false;
+
+ if ($dbc->Errors->Count > 0) return $false;
+ if (! $rs) return $false;
- if ($rs->State == 0) return true; // 0 = adStateClosed means no records returned
+ if ($rs->State == 0) {
+ $true = true;
+ return $true; // 0 = adStateClosed means no records returned
+ }
return $rs;
}
@@ -348,7 +347,7 @@ class ADORecordSet_ado extends ADORecordSet {
$o->ado_type = $t;
- //print "off=$off name=$o->name type=$o->type len=$o->max_length ";
+ //print "off=$off name=$o->name type=$o->type len=$o->max_length ";
return $o;
}
diff --git a/lib/adodb/drivers/adodb-ado5.inc.php b/lib/adodb/drivers/adodb-ado5.inc.php
new file mode 100644
index 00000000000..2791167b82c
--- /dev/null
+++ b/lib/adodb/drivers/adodb-ado5.inc.php
@@ -0,0 +1,636 @@
+_affectedRows = new VARIANT;
+ }
+
+ function ServerInfo()
+ {
+ if (!empty($this->_connectionID)) $desc = $this->_connectionID->provider;
+ return array('description' => $desc, 'version' => '');
+ }
+
+ function _affectedrows()
+ {
+ if (PHP_VERSION >= 5) return $this->_affectedRows;
+
+ return $this->_affectedRows->value;
+ }
+
+ // you can also pass a connection string like this:
+ //
+ // $DB->Connect('USER ID=sa;PASSWORD=pwd;SERVER=mangrove;DATABASE=ai',false,false,'SQLOLEDB');
+ function _connect($argHostname, $argUsername, $argPassword, $argProvider= 'MSDASQL')
+ {
+ try {
+ $u = 'UID';
+ $p = 'PWD';
+
+ if (!empty($this->charPage))
+ $dbc = new COM('ADODB.Connection',null,$this->charPage);
+ else
+ $dbc = new COM('ADODB.Connection');
+
+ if (! $dbc) return false;
+
+ /* special support if provider is mssql or access */
+ if ($argProvider=='mssql') {
+ $u = 'User Id'; //User parameter name for OLEDB
+ $p = 'Password';
+ $argProvider = "SQLOLEDB"; // SQL Server Provider
+
+ // not yet
+ //if ($argDatabasename) $argHostname .= ";Initial Catalog=$argDatabasename";
+
+ //use trusted conection for SQL if username not specified
+ if (!$argUsername) $argHostname .= ";Trusted_Connection=Yes";
+ } else if ($argProvider=='access')
+ $argProvider = "Microsoft.Jet.OLEDB.4.0"; // Microsoft Jet Provider
+
+ if ($argProvider) $dbc->Provider = $argProvider;
+
+ if ($argUsername) $argHostname .= ";$u=$argUsername";
+ if ($argPassword)$argHostname .= ";$p=$argPassword";
+
+ if ($this->debug) ADOConnection::outp( "Host=".$argHostname." \n version=$dbc->version");
+ // @ added below for php 4.0.1 and earlier
+ @$dbc->Open((string) $argHostname);
+
+ $this->_connectionID = $dbc;
+
+ $dbc->CursorLocation = $this->_cursor_location;
+ return $dbc->State > 0;
+ } catch (exception $e) {
+ }
+
+ return false;
+ }
+
+ // returns true or false
+ function _pconnect($argHostname, $argUsername, $argPassword, $argProvider='MSDASQL')
+ {
+ return $this->_connect($argHostname,$argUsername,$argPassword,$argProvider);
+ }
+
+/*
+ adSchemaCatalogs = 1,
+ adSchemaCharacterSets = 2,
+ adSchemaCollations = 3,
+ adSchemaColumns = 4,
+ adSchemaCheckConstraints = 5,
+ adSchemaConstraintColumnUsage = 6,
+ adSchemaConstraintTableUsage = 7,
+ adSchemaKeyColumnUsage = 8,
+ adSchemaReferentialContraints = 9,
+ adSchemaTableConstraints = 10,
+ adSchemaColumnsDomainUsage = 11,
+ adSchemaIndexes = 12,
+ adSchemaColumnPrivileges = 13,
+ adSchemaTablePrivileges = 14,
+ adSchemaUsagePrivileges = 15,
+ adSchemaProcedures = 16,
+ adSchemaSchemata = 17,
+ adSchemaSQLLanguages = 18,
+ adSchemaStatistics = 19,
+ adSchemaTables = 20,
+ adSchemaTranslations = 21,
+ adSchemaProviderTypes = 22,
+ adSchemaViews = 23,
+ adSchemaViewColumnUsage = 24,
+ adSchemaViewTableUsage = 25,
+ adSchemaProcedureParameters = 26,
+ adSchemaForeignKeys = 27,
+ adSchemaPrimaryKeys = 28,
+ adSchemaProcedureColumns = 29,
+ adSchemaDBInfoKeywords = 30,
+ adSchemaDBInfoLiterals = 31,
+ adSchemaCubes = 32,
+ adSchemaDimensions = 33,
+ adSchemaHierarchies = 34,
+ adSchemaLevels = 35,
+ adSchemaMeasures = 36,
+ adSchemaProperties = 37,
+ adSchemaMembers = 38
+
+*/
+
+ function &MetaTables()
+ {
+ $arr= array();
+ $dbc = $this->_connectionID;
+
+ $adors=@$dbc->OpenSchema(20);//tables
+ if ($adors){
+ $f = $adors->Fields(2);//table/view name
+ $t = $adors->Fields(3);//table type
+ while (!$adors->EOF){
+ $tt=substr($t->value,0,6);
+ if ($tt!='SYSTEM' && $tt !='ACCESS')
+ $arr[]=$f->value;
+ //print $f->value . ' ' . $t->value.' ';
+ $adors->MoveNext();
+ }
+ $adors->Close();
+ }
+
+ return $arr;
+ }
+
+ function &MetaColumns($table)
+ {
+ $table = strtoupper($table);
+ $arr= array();
+ $dbc = $this->_connectionID;
+
+ $adors=@$dbc->OpenSchema(4);//tables
+
+ if ($adors){
+ $t = $adors->Fields(2);//table/view name
+ while (!$adors->EOF){
+
+
+ if (strtoupper($t->Value) == $table) {
+
+ $fld = new ADOFieldObject();
+ $c = $adors->Fields(3);
+ $fld->name = $c->Value;
+ $fld->type = 'CHAR'; // cannot discover type in ADO!
+ $fld->max_length = -1;
+ $arr[strtoupper($fld->name)]=$fld;
+ }
+
+ $adors->MoveNext();
+ }
+ $adors->Close();
+ }
+
+ return $arr;
+ }
+
+
+
+
+ /* returns queryID or false */
+ function &_query($sql,$inputarr=false)
+ {
+ try { // In PHP5, all COM errors are exceptions, so to maintain old behaviour...
+
+ $dbc = $this->_connectionID;
+
+ // return rs
+ if ($inputarr) {
+
+ if (!empty($this->charPage))
+ $oCmd = new COM('ADODB.Command',null,$this->charPage);
+ else
+ $oCmd = new COM('ADODB.Command');
+ $oCmd->ActiveConnection = $dbc;
+ $oCmd->CommandText = $sql;
+ $oCmd->CommandType = 1;
+
+ foreach($inputarr as $val) {
+ // name, type, direction 1 = input, len,
+ $this->adoParameterType = 130;
+ $p = $oCmd->CreateParameter('name',$this->adoParameterType,1,strlen($val),$val);
+ //print $p->Type.' '.$p->value;
+ $oCmd->Parameters->Append($p);
+ }
+ $p = false;
+ $rs = $oCmd->Execute();
+ $e = $dbc->Errors;
+ if ($dbc->Errors->Count > 0) return false;
+ return $rs;
+ }
+
+ $rs = @$dbc->Execute($sql,$this->_affectedRows, $this->_execute_option);
+
+ if ($dbc->Errors->Count > 0) return false;
+ if (! $rs) return false;
+
+ if ($rs->State == 0) return true; // 0 = adStateClosed means no records returned
+ return $rs;
+
+ } catch (exception $e) {
+
+ }
+ return false;
+ }
+
+
+ function BeginTrans()
+ {
+ if ($this->transOff) return true;
+
+ if (isset($this->_thisTransactions))
+ if (!$this->_thisTransactions) return false;
+ else {
+ $o = $this->_connectionID->Properties("Transaction DDL");
+ $this->_thisTransactions = $o ? true : false;
+ if (!$o) return false;
+ }
+ @$this->_connectionID->BeginTrans();
+ $this->transCnt += 1;
+ return true;
+ }
+ function CommitTrans($ok=true)
+ {
+ if (!$ok) return $this->RollbackTrans();
+ if ($this->transOff) return true;
+
+ @$this->_connectionID->CommitTrans();
+ if ($this->transCnt) @$this->transCnt -= 1;
+ return true;
+ }
+ function RollbackTrans() {
+ if ($this->transOff) return true;
+ @$this->_connectionID->RollbackTrans();
+ if ($this->transCnt) @$this->transCnt -= 1;
+ return true;
+ }
+
+ /* Returns: the last error message from previous database operation */
+
+ function ErrorMsg()
+ {
+ $errc = $this->_connectionID->Errors;
+ if ($errc->Count == 0) return '';
+ $err = $errc->Item($errc->Count-1);
+ return $err->Description;
+ }
+
+ function ErrorNo()
+ {
+ $errc = $this->_connectionID->Errors;
+ if ($errc->Count == 0) return 0;
+ $err = $errc->Item($errc->Count-1);
+ return $err->NativeError;
+ }
+
+ // returns true or false
+ function _close()
+ {
+ if ($this->_connectionID) $this->_connectionID->Close();
+ $this->_connectionID = false;
+ return true;
+ }
+
+
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordSet_ado extends ADORecordSet {
+
+ var $bind = false;
+ var $databaseType = "ado";
+ var $dataProvider = "ado";
+ var $_tarr = false; // caches the types
+ var $_flds; // and field objects
+ var $canSeek = true;
+ var $hideErrors = true;
+
+ function ADORecordSet_ado($id,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ $this->fetchMode = $mode;
+ return $this->ADORecordSet($id,$mode);
+ }
+
+
+ // returns the field object
+ function FetchField($fieldOffset = -1) {
+ $off=$fieldOffset+1; // offsets begin at 1
+
+ $o= new ADOFieldObject();
+ $rs = $this->_queryID;
+ $f = $rs->Fields($fieldOffset);
+ $o->name = $f->Name;
+ $t = $f->Type;
+ $o->type = $this->MetaType($t);
+ $o->max_length = $f->DefinedSize;
+ $o->ado_type = $t;
+
+
+ //print "off=$off name=$o->name type=$o->type len=$o->max_length ";
+ 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()
+ {
+ $rs = $this->_queryID;
+ $this->_numOfRows = $rs->RecordCount;
+
+ $f = $rs->Fields;
+ $this->_numOfFields = $f->Count;
+ }
+
+
+ // should only be used to move forward as we normally use forward-only cursors
+ function _seek($row)
+ {
+ $rs = $this->_queryID;
+ // absoluteposition doesn't work -- my maths is wrong ?
+ // $rs->AbsolutePosition->$row-2;
+ // return true;
+ if ($this->_currentRow > $row) return false;
+ @$rs->Move((integer)$row - $this->_currentRow-1); //adBookmarkFirst
+ return true;
+ }
+
+/*
+ OLEDB types
+
+ enum DBTYPEENUM
+ { DBTYPE_EMPTY = 0,
+ DBTYPE_NULL = 1,
+ DBTYPE_I2 = 2,
+ DBTYPE_I4 = 3,
+ DBTYPE_R4 = 4,
+ DBTYPE_R8 = 5,
+ DBTYPE_CY = 6,
+ DBTYPE_DATE = 7,
+ DBTYPE_BSTR = 8,
+ DBTYPE_IDISPATCH = 9,
+ DBTYPE_ERROR = 10,
+ DBTYPE_BOOL = 11,
+ DBTYPE_VARIANT = 12,
+ DBTYPE_IUNKNOWN = 13,
+ DBTYPE_DECIMAL = 14,
+ DBTYPE_UI1 = 17,
+ DBTYPE_ARRAY = 0x2000,
+ DBTYPE_BYREF = 0x4000,
+ DBTYPE_I1 = 16,
+ DBTYPE_UI2 = 18,
+ DBTYPE_UI4 = 19,
+ DBTYPE_I8 = 20,
+ DBTYPE_UI8 = 21,
+ DBTYPE_GUID = 72,
+ DBTYPE_VECTOR = 0x1000,
+ DBTYPE_RESERVED = 0x8000,
+ DBTYPE_BYTES = 128,
+ DBTYPE_STR = 129,
+ DBTYPE_WSTR = 130,
+ DBTYPE_NUMERIC = 131,
+ DBTYPE_UDT = 132,
+ DBTYPE_DBDATE = 133,
+ DBTYPE_DBTIME = 134,
+ DBTYPE_DBTIMESTAMP = 135
+
+ ADO Types
+
+ adEmpty = 0,
+ adTinyInt = 16,
+ adSmallInt = 2,
+ adInteger = 3,
+ adBigInt = 20,
+ adUnsignedTinyInt = 17,
+ adUnsignedSmallInt = 18,
+ adUnsignedInt = 19,
+ adUnsignedBigInt = 21,
+ adSingle = 4,
+ adDouble = 5,
+ adCurrency = 6,
+ adDecimal = 14,
+ adNumeric = 131,
+ adBoolean = 11,
+ adError = 10,
+ adUserDefined = 132,
+ adVariant = 12,
+ adIDispatch = 9,
+ adIUnknown = 13,
+ adGUID = 72,
+ adDate = 7,
+ adDBDate = 133,
+ adDBTime = 134,
+ adDBTimeStamp = 135,
+ adBSTR = 8,
+ adChar = 129,
+ adVarChar = 200,
+ adLongVarChar = 201,
+ adWChar = 130,
+ adVarWChar = 202,
+ adLongVarWChar = 203,
+ adBinary = 128,
+ adVarBinary = 204,
+ adLongVarBinary = 205,
+ adChapter = 136,
+ adFileTime = 64,
+ adDBFileTime = 137,
+ adPropVariant = 138,
+ adVarNumeric = 139
+*/
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+
+ if (!is_numeric($t)) return $t;
+
+ switch ($t) {
+ case 0:
+ case 12: // variant
+ case 8: // bstr
+ case 129: //char
+ case 130: //wc
+ case 200: // varc
+ case 202:// varWC
+ case 128: // bin
+ case 204: // varBin
+ case 72: // guid
+ if ($len <= $this->blobSize) return 'C';
+
+ case 201:
+ case 203:
+ return 'X';
+ case 128:
+ case 204:
+ case 205:
+ return 'B';
+ case 7:
+ case 133: return 'D';
+
+ case 134:
+ case 135: return 'T';
+
+ case 11: return 'L';
+
+ case 16:// adTinyInt = 16,
+ case 2://adSmallInt = 2,
+ case 3://adInteger = 3,
+ case 4://adBigInt = 20,
+ case 17://adUnsignedTinyInt = 17,
+ case 18://adUnsignedSmallInt = 18,
+ case 19://adUnsignedInt = 19,
+ case 20://adUnsignedBigInt = 21,
+ return 'I';
+ default: return 'N';
+ }
+ }
+
+ // time stamp not supported yet
+ function _fetch()
+ {
+ $rs = $this->_queryID;
+ if (!$rs or $rs->EOF) {
+ $this->fields = false;
+ return false;
+ }
+ $this->fields = array();
+
+ if (!$this->_tarr) {
+ $tarr = array();
+ $flds = array();
+ for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) {
+ $f = $rs->Fields($i);
+ $flds[] = $f;
+ $tarr[] = $f->Type;
+ }
+ // bind types and flds only once
+ $this->_tarr = $tarr;
+ $this->_flds = $flds;
+ }
+ $t = reset($this->_tarr);
+ $f = reset($this->_flds);
+
+ if ($this->hideErrors) $olde = error_reporting(E_ERROR|E_CORE_ERROR);// sometimes $f->value be null
+ for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) {
+ //echo "",$t,' ';var_dump($f->value); echo '
';
+ switch($t) {
+ case 135: // timestamp
+ if (!strlen((string)$f->value)) $this->fields[] = false;
+ else {
+ if (!is_numeric($f->value)) $val = variant_date_to_timestamp($f->value);
+ else $val = $f->value;
+ $this->fields[] = adodb_date('Y-m-d H:i:s',$val);
+ }
+ break;
+ case 133:// A date value (yyyymmdd)
+ if ($val = $f->value) {
+ $this->fields[] = substr($val,0,4).'-'.substr($val,4,2).'-'.substr($val,6,2);
+ } else
+ $this->fields[] = false;
+ break;
+ case 7: // adDate
+ if (!strlen((string)$f->value)) $this->fields[] = false;
+ else {
+ if (!is_numeric($f->value)) $val = variant_date_to_timestamp($f->value);
+ else $val = $f->value;
+
+ if (($val % 86400) == 0) $this->fields[] = adodb_date('Y-m-d',$val);
+ else $this->fields[] = adodb_date('Y-m-d H:i:s',$val);
+ }
+ break;
+ case 1: // null
+ $this->fields[] = false;
+ break;
+ case 6: // currency is not supported properly;
+ ADOConnection::outp( ''.$f->Name.': currency type not supported by PHP ');
+ $this->fields[] = (float) $f->value;
+ break;
+ default:
+ $this->fields[] = $f->value;
+ break;
+ }
+ //print " $f->value $t, ";
+ $f = next($this->_flds);
+ $t = next($this->_tarr);
+ } // for
+ if ($this->hideErrors) error_reporting($olde);
+ @$rs->MoveNext(); // @ needed for some versions of PHP!
+
+ if ($this->fetchMode & ADODB_FETCH_ASSOC) {
+ $this->fields = &$this->GetRowAssoc(ADODB_ASSOC_CASE);
+ }
+ return true;
+ }
+
+ function NextRecordSet()
+ {
+ $rs = $this->_queryID;
+ $this->_queryID = $rs->NextRecordSet();
+ //$this->_queryID = $this->_QueryId->NextRecordSet();
+ if ($this->_queryID == null) return false;
+
+ $this->_currentRow = -1;
+ $this->_currentPage = -1;
+ $this->bind = false;
+ $this->fields = false;
+ $this->_flds = false;
+ $this->_tarr = false;
+
+ $this->_inited = false;
+ $this->Init();
+ return true;
+ }
+
+ function _close() {
+ $this->_flds = false;
+ @$this->_queryID->Close();// by Pete Dishman (peterd@telephonetics.co.uk)
+ $this->_queryID = false;
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/lib/adodb/drivers/adodb-ado_access.inc.php b/lib/adodb/drivers/adodb-ado_access.inc.php
index 72ff6deebe6..f8f4ab75dcd 100644
--- a/lib/adodb/drivers/adodb-ado_access.inc.php
+++ b/lib/adodb/drivers/adodb-ado_access.inc.php
@@ -1,6 +1,6 @@
= 5) include(ADODB_DIR."/drivers/adodb-ado5.inc.php");
+ else include(ADODB_DIR."/drivers/adodb-ado.inc.php");
}
class ADODB_ado_access extends ADODB_ado {
@@ -33,6 +34,10 @@ class ADODB_ado_access extends ADODB_ado {
}
function BeginTrans() { return false;}
+
+ function CommitTrans() { return false;}
+
+ function RollbackTrans() { return false;}
}
diff --git a/lib/adodb/drivers/adodb-ado_mssql.inc.php b/lib/adodb/drivers/adodb-ado_mssql.inc.php
index 28a31495838..64aeeea12f4 100644
--- a/lib/adodb/drivers/adodb-ado_mssql.inc.php
+++ b/lib/adodb/drivers/adodb-ado_mssql.inc.php
@@ -1,6 +1,6 @@
= 5) include(ADODB_DIR."/drivers/adodb-ado5.inc.php");
+ else include(ADODB_DIR."/drivers/adodb-ado.inc.php");
}
@@ -54,35 +55,36 @@ class ADODB_ado_mssql extends ADODB_ado {
function MetaColumns($table)
{
- $table = strtoupper($table);
- $arr= array();
- $dbc = $this->_connectionID;
-
- $osoptions = array();
- $osoptions[0] = null;
- $osoptions[1] = null;
- $osoptions[2] = $table;
- $osoptions[3] = null;
-
- $adors=@$dbc->OpenSchema(4, $osoptions);//tables
+ $table = strtoupper($table);
+ $arr= array();
+ $dbc = $this->_connectionID;
+
+ $osoptions = array();
+ $osoptions[0] = null;
+ $osoptions[1] = null;
+ $osoptions[2] = $table;
+ $osoptions[3] = null;
+
+ $adors=@$dbc->OpenSchema(4, $osoptions);//tables
+
+ if ($adors){
+ while (!$adors->EOF){
+ $fld = new ADOFieldObject();
+ $c = $adors->Fields(3);
+ $fld->name = $c->Value;
+ $fld->type = 'CHAR'; // cannot discover type in ADO!
+ $fld->max_length = -1;
+ $arr[strtoupper($fld->name)]=$fld;
+
+ $adors->MoveNext();
+ }
+ $adors->Close();
+ }
+ $false = false;
+ return empty($arr) ? $false : $arr;
+ }
- if ($adors){
- while (!$adors->EOF){
- $fld = new ADOFieldObject();
- $c = $adors->Fields(3);
- $fld->name = $c->Value;
- $fld->type = 'CHAR'; // cannot discover type in ADO!
- $fld->max_length = -1;
- $arr[strtoupper($fld->name)]=$fld;
-
- $adors->MoveNext();
- }
- $adors->Close();
- }
-
- return $arr;
- }
- }
+ } // end class
class ADORecordSet_ado_mssql extends ADORecordSet_ado {
diff --git a/lib/adodb/drivers/adodb-borland_ibase.inc.php b/lib/adodb/drivers/adodb-borland_ibase.inc.php
index 3d71ac6819b..3c65235d0f5 100644
--- a/lib/adodb/drivers/adodb-borland_ibase.inc.php
+++ b/lib/adodb/drivers/adodb-borland_ibase.inc.php
@@ -1,6 +1,6 @@
_url.'?sql='.urlencode($sql)."&nrows=$nrows&fetch=".
+ $url = $this->_url.'?sql='.urlencode($sql)."&nrows=$nrows&fetch=".
(($this->fetchMode !== false)?$this->fetchMode : $ADODB_FETCH_MODE).
- "&offset=$offset";
+ "&offset=$offset";
$err = false;
$rs = csv2rs($url,$err,false);
- if ($this->debug) print "$url$err ";
+ if ($this->debug) print "$url$err ";
$at = strpos($err,'::::');
if ($at === false) {
@@ -136,13 +136,13 @@ class ADODB_csv extends ADOConnection {
$inputarr = false;
}
- $url = $this->_url.'?sql='.urlencode($sql)."&fetch=".
+ $url = $this->_url.'?sql='.urlencode($sql)."&fetch=".
(($this->fetchMode !== false)?$this->fetchMode : $ADODB_FETCH_MODE);
$err = false;
$rs = csv2rs($url,$err,false);
- if ($this->debug) print urldecode($url)."$err ";
+ if ($this->debug) print urldecode($url)."$err ";
$at = strpos($err,'::::');
if ($at === false) {
$this->_errorMsg = $err;
diff --git a/lib/adodb/drivers/adodb-db2.inc.php b/lib/adodb/drivers/adodb-db2.inc.php
index 09b0611ff8d..3bbb8e7c4e3 100644
--- a/lib/adodb/drivers/adodb-db2.inc.php
+++ b/lib/adodb/drivers/adodb-db2.inc.php
@@ -1,6 +1,6 @@
_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
$arr =& $rs->GetArray();
@@ -175,7 +177,45 @@ class ADODB_DB2 extends ADODB_odbc {
}
return $arr2;
}
-
+
+ function &MetaIndexes ($table, $primary = FALSE, $owner=false)
+ {
+ // save old fetch mode
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
+ $false = false;
+ // get index details
+ $table = strtoupper($table);
+ $SQL="SELECT NAME, UNIQUERULE, COLNAMES FROM SYSIBM.SYSINDEXES WHERE TBNAME='$table'";
+ if ($primary)
+ $SQL.= " AND UNIQUERULE='P'";
+ $rs = $this->Execute($SQL);
+ if (!is_object($rs)) {
+ if (isset($savem))
+ $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ return $false;
+ }
+ $indexes = array ();
+ // parse index data into array
+ while ($row = $rs->FetchRow()) {
+ $indexes[$row[0]] = array(
+ 'unique' => ($row[1] == 'U' || $row[1] == 'P'),
+ 'columns' => array()
+ );
+ $cols = ltrim($row[2],'+');
+ $indexes[$row[0]]['columns'] = explode('+', $cols);
+ }
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ }
+ return $indexes;
+ }
// Format date column in sql string given an input format that understands Y M D
function SQLDate($fmt, $col=false)
@@ -274,12 +314,14 @@ class ADORecordSet_db2 extends ADORecordSet_odbc {
case 'VARCHAR':
case 'CHAR':
case 'CHARACTER':
+ case 'C':
if ($len <= $this->blobSize) return 'C';
case 'LONGCHAR':
case 'TEXT':
case 'CLOB':
case 'DBCLOB': // double-byte
+ case 'X':
return 'X';
case 'BLOB':
@@ -288,10 +330,12 @@ class ADORecordSet_db2 extends ADORecordSet_odbc {
return 'B';
case 'DATE':
+ case 'D':
return 'D';
case 'TIME':
case 'TIMESTAMP':
+ case 'T':
return 'T';
//case 'BOOLEAN':
@@ -305,6 +349,7 @@ class ADORecordSet_db2 extends ADORecordSet_odbc {
case 'INTEGER':
case 'BIGINT':
case 'SMALLINT':
+ case 'I':
return 'I';
default: return 'N';
diff --git a/lib/adodb/drivers/adodb-fbsql.inc.php b/lib/adodb/drivers/adodb-fbsql.inc.php
index 308ebca3a4b..5950990f635 100644
--- a/lib/adodb/drivers/adodb-fbsql.inc.php
+++ b/lib/adodb/drivers/adodb-fbsql.inc.php
@@ -1,6 +1,6 @@
fetchMode = FBSQL_NUM; break;
- default:
- case ADODB_FETCH_BOTH: $this->fetchMode = FBSQL_BOTH; break;
case ADODB_FETCH_ASSOC: $this->fetchMode = FBSQL_ASSOC; break;
+ case ADODB_FETCH_BOTH:
+ default:
+ $this->fetchMode = FBSQL_BOTH; break;
}
return $this->ADORecordSet($queryID);
}
diff --git a/lib/adodb/drivers/adodb-firebird.inc.php b/lib/adodb/drivers/adodb-firebird.inc.php
index 3ac23bdb23e..406c3ebb17d 100644
--- a/lib/adodb/drivers/adodb-firebird.inc.php
+++ b/lib/adodb/drivers/adodb-firebird.inc.php
@@ -1,6 +1,6 @@
metaColumnsSQL) {
-
- $save = $ADODB_FETCH_MODE;
- $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
-
- $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table)));
-
- $ADODB_FETCH_MODE = $save;
- if ($rs === false) return false;
-
- $retarr = array();
- //OPN STUFF start
- $dialect3 = ($this->dialect==3 ? true : false);
- //OPN STUFF end
- while (!$rs->EOF) { //print_r($rs->fields);
- $fld = new ADOFieldObject();
- $fld->name = trim($rs->fields[0]);
- //OPN STUFF start
- $this->_ConvertFieldType($fld, $rs->fields[7], $rs->fields[3], $rs->fields[4], $rs->fields[5], $rs->fields[6], $dialect3);
- if (isset($rs->fields[1]) && $rs->fields[1]) {
- $fld->not_null = true;
- }
- if (isset($rs->fields[2])) {
-
- $fld->has_default = true;
- $d = substr($rs->fields[2],strlen('default '));
- switch ($fld->type)
- {
- case 'smallint':
- case 'integer': $fld->default_value = (int) $d; break;
- case 'char':
- case 'blob':
- case 'text':
- case 'varchar': $fld->default_value = (string) substr($d,1,strlen($d)-2); break;
- case 'double':
- case 'float': $fld->default_value = (float) $d; break;
- default: $fld->default_value = $d; break;
- }
- // case 35:$tt = 'TIMESTAMP'; break;
- }
- if ((isset($rs->fields[5])) && ($fld->type == 'blob')) {
- $fld->sub_type = $rs->fields[5];
- } else {
- $fld->sub_type = null;
- }
- //OPN STUFF end
- if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
- else $retarr[strtoupper($fld->name)] = $fld;
-
- $rs->MoveNext();
- }
- $rs->Close();
- return $retarr;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+
+ $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table)));
+
+ $ADODB_FETCH_MODE = $save;
+ if ($rs === false) {
+ $false = false;
+ return $false;
}
- return false;
+
+ $retarr = array();
+ //OPN STUFF start
+ $dialect3 = ($this->dialect==3 ? true : false);
+ //OPN STUFF end
+ while (!$rs->EOF) { //print_r($rs->fields);
+ $fld = new ADOFieldObject();
+ $fld->name = trim($rs->fields[0]);
+ //OPN STUFF start
+ $this->_ConvertFieldType($fld, $rs->fields[7], $rs->fields[3], $rs->fields[4], $rs->fields[5], $rs->fields[6], $dialect3);
+ if (isset($rs->fields[1]) && $rs->fields[1]) {
+ $fld->not_null = true;
+ }
+ if (isset($rs->fields[2])) {
+
+ $fld->has_default = true;
+ $d = substr($rs->fields[2],strlen('default '));
+ switch ($fld->type)
+ {
+ case 'smallint':
+ case 'integer': $fld->default_value = (int) $d; break;
+ case 'char':
+ case 'blob':
+ case 'text':
+ case 'varchar': $fld->default_value = (string) substr($d,1,strlen($d)-2); break;
+ case 'double':
+ case 'float': $fld->default_value = (float) $d; break;
+ default: $fld->default_value = $d; break;
+ }
+ // case 35:$tt = 'TIMESTAMP'; break;
+ }
+ if ((isset($rs->fields[5])) && ($fld->type == 'blob')) {
+ $fld->sub_type = $rs->fields[5];
+ } else {
+ $fld->sub_type = null;
+ }
+ //OPN STUFF end
+ if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
+ else $retarr[strtoupper($fld->name)] = $fld;
+
+ $rs->MoveNext();
+ }
+ $rs->Close();
+ return empty($retarr) ? false : $retarr;
}
function BlobEncode( $blob )
diff --git a/lib/adodb/drivers/adodb-informix.inc.php b/lib/adodb/drivers/adodb-informix.inc.php
index 95bdc1d318e..70a9dbe5c2a 100644
--- a/lib/adodb/drivers/adodb-informix.inc.php
+++ b/lib/adodb/drivers/adodb-informix.inc.php
@@ -1,6 +1,6 @@
ADORecordset_informix72($id,$mode);
diff --git a/lib/adodb/drivers/adodb-informix72.inc.php b/lib/adodb/drivers/adodb-informix72.inc.php
index b2e53dec094..b888f4ea478 100644
--- a/lib/adodb/drivers/adodb-informix72.inc.php
+++ b/lib/adodb/drivers/adodb-informix72.inc.php
@@ -1,6 +1,6 @@
version)) return $this->version;
$arr['description'] = $this->GetOne("select DBINFO('version','full') from systables where tabid = 1");
- $arr['version'] = $this->GetOne("select DBINFO('version','major')||"."||DBINFO('version','minor') from systables where tabid = 1");
+ $arr['version'] = $this->GetOne("select DBINFO('version','major') || DBINFO('version','minor') from systables where tabid = 1");
$this->version = $arr;
return $arr;
}
@@ -141,7 +141,7 @@ class ADODB_informix72 extends ADOConnection {
function ErrorNo()
{
- preg_match("/.*SQLCODE=([^\]]*)/",ifx_error(),$parse); //!EOS
+ preg_match("/.*SQLCODE=([^\]]*)/",ifx_error(),$parse);
if (is_array($parse) && isset($parse[1])) return (int)$parse[1];
return 0;
}
@@ -165,9 +165,20 @@ class ADODB_informix72 extends ADOConnection {
while (!$rs->EOF) { //print_r($rs->fields);
$fld = new ADOFieldObject();
$fld->name = $rs->fields[0];
+/* //!eos.
+ $rs->fields[1] is not the correct adodb type
+ $rs->fields[2] is not correct max_length, because can include not-null bit
+
$fld->type = $rs->fields[1];
$fld->primary_key=$rspkey->fields && array_search($rs->fields[4],$rspkey->fields); //Added to set primary key flag
- $fld->max_length = $rs->fields[2];
+ $fld->max_length = $rs->fields[2];*/
+ $pr=ifx_props($rs->fields[1],$rs->fields[2]); //!eos
+ $fld->type = $pr[0] ;//!eos
+ $fld->primary_key=$rspkey->fields && array_search($rs->fields[4],$rspkey->fields);
+ $fld->max_length = $pr[1]; //!eos
+ $fld->precision = $pr[2] ;//!eos
+ $fld->not_null = $pr[3]=="N"; //!eos
+
if (trim($rs->fields[3]) != "AAAAAA 0") {
$fld->has_default = 1;
$fld->default_value = $rs->fields[3];
@@ -180,6 +191,7 @@ class ADODB_informix72 extends ADOConnection {
}
$rs->Close();
+ $rspKey->Close(); //!eos
return $retarr;
}
@@ -191,6 +203,38 @@ class ADODB_informix72 extends ADOConnection {
return ADOConnection::MetaColumns($table,false);
}
+ function MetaForeignKeys($table, $owner=false, $upper=false) //!Eos
+ {
+ $sql = "
+ select tr.tabname,updrule,delrule,
+ i.part1 o1,i2.part1 d1,i.part2 o2,i2.part2 d2,i.part3 o3,i2.part3 d3,i.part4 o4,i2.part4 d4,
+ i.part5 o5,i2.part5 d5,i.part6 o6,i2.part6 d6,i.part7 o7,i2.part7 d7,i.part8 o8,i2.part8 d8
+ from systables t,sysconstraints s,sysindexes i,
+ sysreferences r,systables tr,sysconstraints s2,sysindexes i2
+ where t.tabname='$table'
+ and s.tabid=t.tabid and s.constrtype='R' and r.constrid=s.constrid
+ and i.idxname=s.idxname and tr.tabid=r.ptabid
+ and s2.constrid=r.primary and i2.idxname=s2.idxname";
+
+ $rs = $this->Execute($sql);
+ if (!$rs || $rs->EOF) return false;
+ $arr =& $rs->GetArray();
+ $a = array();
+ foreach($arr as $v) {
+ $coldest=$this->metaColumnNames($v["tabname"]);
+ $colorig=$this->metaColumnNames($table);
+ $colnames=array();
+ for($i=1;$i<=8 && $v["o$i"] ;$i++) {
+ $colnames[]=$coldest[$v["d$i"]-1]."=".$colorig[$v["o$i"]-1];
+ }
+ if($upper)
+ $a[strtoupper($v["tabname"])] = $colnames;
+ else
+ $a[$v["tabname"]] = $colnames;
+ }
+ return $a;
+ }
+
function UpdateBlob($table, $column, $val, $where, $blobtype = 'BLOB')
{
$type = ($blobtype == 'TEXT') ? 1 : 0;
@@ -342,7 +386,7 @@ class ADORecordset_informix72 extends ADORecordSet {
function _seek($row)
{
- return @ifx_fetch_row($this->_queryID, $row);
+ return @ifx_fetch_row($this->_queryID, (int) $row);
}
function MoveLast()
@@ -401,4 +445,29 @@ class ADORecordset_informix72 extends ADORecordSet {
}
}
+/** !Eos
+* Auxiliar function to Parse coltype,collength. Used by Metacolumns
+* return: array ($mtype,$length,$precision,$nullable) (similar to ifx_fieldpropierties)
+*/
+function ifx_props($coltype,$collength){
+ $itype=fmod($coltype+1,256);
+ $nullable=floor(($coltype+1) /256) ?"N":"Y";
+ $mtype=substr(" CIIFFNNDN TBXCC ",$itype,1);
+ switch ($itype){
+ case 2:
+ $length=4;
+ case 6:
+ case 9:
+ case 14:
+ $length=floor($collength/256);
+ $precision=fmod($collength,256);
+ break;
+ default:
+ $precision=0;
+ $length=$collength;
+ }
+ return array($mtype,$length,$precision,$nullable);
+}
+
+
?>
\ No newline at end of file
diff --git a/lib/adodb/drivers/adodb-ldap.inc.php b/lib/adodb/drivers/adodb-ldap.inc.php
index cea5014f0ab..40a4aefe421 100644
--- a/lib/adodb/drivers/adodb-ldap.inc.php
+++ b/lib/adodb/drivers/adodb-ldap.inc.php
@@ -1,6 +1,6 @@
version ) ) return $this->version;
+ if( !empty( $this->version ) ) return $this->version;
$version = array();
/*
Determines how aliases are handled during search.
@@ -160,8 +160,8 @@ class ADODB_ldap extends ADOConnection {
}
/* The host name (or list of hosts) for the primary LDAP server. */
ldap_get_option( $this->_connectionID, LDAP_OPT_HOST_NAME, $version['LDAP_OPT_HOST_NAME'] );
- ldap_get_option( $this->_connectionID, OPT_ERROR_NUMBER, $version['OPT_ERROR_NUMBER'] );
- ldap_get_option( $this->_connectionID, OPT_ERROR_STRING, $version['OPT_ERROR_STRING'] );
+ ldap_get_option( $this->_connectionID, LDAP_OPT_ERROR_NUMBER, $version['LDAP_OPT_ERROR_NUMBER'] );
+ ldap_get_option( $this->_connectionID, LDAP_OPT_ERROR_STRING, $version['lDAP_OPT_ERROR_STRING'] );
ldap_get_option( $this->_connectionID, LDAP_OPT_MATCHED_DN, $version['LDAP_OPT_MATCHED_DN'] );
return $this->version = $version;
@@ -193,9 +193,9 @@ class ADORecordSet_ldap extends ADORecordSet{
case ADODB_FETCH_ASSOC:
$this->fetchMode = LDAP_ASSOC;
break;
- default:
case ADODB_FETCH_DEFAULT:
case ADODB_FETCH_BOTH:
+ default:
$this->fetchMode = LDAP_BOTH;
break;
}
diff --git a/lib/adodb/drivers/adodb-mssql.inc.php b/lib/adodb/drivers/adodb-mssql.inc.php
index abc22e1e11d..b2e8274d2c9 100644
--- a/lib/adodb/drivers/adodb-mssql.inc.php
+++ b/lib/adodb/drivers/adodb-mssql.inc.php
@@ -1,6 +1,6 @@
GetOne("select top 1 null as ignore from $tables with (ROWLOCK,HOLDLOCK) where $where");
}
+
+ function &MetaIndexes($table,$primary=false)
+ {
+ $table = $this->qstr($table);
+
+ $sql = "SELECT i.name AS ind_name, C.name AS col_name, USER_NAME(O.uid) AS Owner, c.colid, k.Keyno,
+ CASE WHEN I.indid BETWEEN 1 AND 254 AND (I.status & 2048 = 2048 OR I.Status = 16402 AND O.XType = 'V') THEN 1 ELSE 0 END AS IsPK,
+ CASE WHEN I.status & 2 = 2 THEN 1 ELSE 0 END AS IsUnique
+ FROM dbo.sysobjects o INNER JOIN dbo.sysindexes I ON o.id = i.id
+ INNER JOIN dbo.sysindexkeys K ON I.id = K.id AND I.Indid = K.Indid
+ INNER JOIN dbo.syscolumns c ON K.id = C.id AND K.colid = C.Colid
+ WHERE LEFT(i.name, 8) <> '_WA_Sys_' AND o.status >= 0 AND O.Name LIKE $table
+ ORDER BY O.name, I.Name, K.keyno";
+
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
+
+ $rs = $this->Execute($sql);
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ }
+ $ADODB_FETCH_MODE = $save;
+
+ if (!is_object($rs)) {
+ return FALSE;
+ }
+
+ $indexes = array();
+ while ($row = $rs->FetchRow()) {
+ if (!$primary && $row[5]) continue;
+
+ $indexes[$row[0]]['unique'] = $row[6];
+ $indexes[$row[0]]['columns'][] = $row[1];
+ }
+ return $indexes;
+ }
+
function MetaForeignKeys($table, $owner=false, $upper=false)
{
global $ADODB_FETCH_MODE;
@@ -494,6 +535,30 @@ order by constraint_name, referenced_table_name, keyno";
return array($sql,$stmt);
}
+ // returns concatenated string
+ // MSSQL requires integers to be cast as strings
+ // automatically cast every datatype to VARCHAR(255)
+ // @author David Rogers (introspectshun)
+ function Concat()
+ {
+ $s = "";
+ $arr = func_get_args();
+
+ // Split single record on commas, if possible
+ if (sizeof($arr) == 1) {
+ foreach ($arr as $arg) {
+ $args = explode(',', $arg);
+ }
+ $arr = $args;
+ }
+
+ array_walk($arr, create_function('&$v', '$v = "CAST(" . $v . " AS VARCHAR(255))";'));
+ $s = implode('+',$arr);
+ if (sizeof($arr) > 0) return "$s";
+
+ return '';
+ }
+
/*
Usage:
$stmt = $db->PrepareSP('SP_RUNSOMETHING'); -- takes 2 params, @myid and @group
diff --git a/lib/adodb/drivers/adodb-mssqlpo.inc.php b/lib/adodb/drivers/adodb-mssqlpo.inc.php
index 0cd801c89bc..bd0e4061444 100644
--- a/lib/adodb/drivers/adodb-mssqlpo.inc.php
+++ b/lib/adodb/drivers/adodb-mssqlpo.inc.php
@@ -1,6 +1,6 @@
fetchMode !== FALSE) {
@@ -95,7 +96,7 @@ class ADODB_mysql extends ADOConnection {
$ADODB_FETCH_MODE = $save;
if (!is_object($rs)) {
- return FALSE;
+ return $false;
}
$indexes = array ();
@@ -148,7 +149,8 @@ class ADODB_mysql extends ADOConnection {
function _insertid()
{
- return mysql_insert_id($this->_connectionID);
+ return ADOConnection::GetOne('SELECT LAST_INSERT_ID()');
+ //return mysql_insert_id($this->_connectionID);
}
function GetOne($sql,$inputarr=false)
@@ -368,72 +370,63 @@ class ADODB_mysql extends ADOConnection {
function &MetaColumns($table)
{
-
- if ($this->metaColumnsSQL) {
global $ADODB_FETCH_MODE;
-
- $save = $ADODB_FETCH_MODE;
- $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
- if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
+ $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
+ if (isset($savem)) $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ if (!is_object($rs)) {
+ $false = false;
+ return $false;
+ }
- $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
+ $retarr = array();
+ while (!$rs->EOF){
+ $fld = new ADOFieldObject();
+ $fld->name = $rs->fields[0];
+ $type = $rs->fields[1];
- if (isset($savem)) $this->SetFetchMode($savem);
- $ADODB_FETCH_MODE = $save;
-
- if ($rs === false) return false;
-
- $retarr = array();
- while (!$rs->EOF){
- $fld = new ADOFieldObject();
- $fld->name = $rs->fields[0];
- $type = $rs->fields[1];
+ // split type into type(length):
+ $fld->scale = null;
+ if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) {
+ $fld->type = $query_array[1];
+ $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
+ $fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1;
+ } elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) {
+ $fld->type = $query_array[1];
+ $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
+ } else {
+ $fld->type = $type;
+ $fld->max_length = -1;
+ }
+ $fld->not_null = ($rs->fields[2] != 'YES');
+ $fld->primary_key = ($rs->fields[3] == 'PRI');
+ $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
+ $fld->binary = (strpos($type,'blob') !== false);
+ $fld->unsigned = (strpos($type,'unsigned') !== false);
-
- // split type into type(length):
- $fld->scale = null;
- if (strpos($type,',') && preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) {
- $fld->type = $query_array[1];
- $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
- $fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1;
- } elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) {
- $fld->type = $query_array[1];
- $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
+ if (!$fld->binary) {
+ $d = $rs->fields[4];
+ if ($d != '' && $d != 'NULL') {
+ $fld->has_default = true;
+ $fld->default_value = $d;
} else {
- $fld->max_length = -1;
- $fld->type = $type;
+ $fld->has_default = false;
}
- /*
- // split type into type(length):
- if (preg_match("/^(.+)\((\d+)/", $type, $query_array)) {
- $fld->type = $query_array[1];
- $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
- } else {
- $fld->max_length = -1;
- $fld->type = $type;
- }*/
- $fld->not_null = ($rs->fields[2] != 'YES');
- $fld->primary_key = ($rs->fields[3] == 'PRI');
- $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
- $fld->binary = (strpos($fld->type,'blob') !== false);
-
- if (!$fld->binary) {
- $d = $rs->fields[4];
- if ($d != "" && $d != "NULL") {
- $fld->has_default = true;
- $fld->default_value = $d;
- } else {
- $fld->has_default = false;
- }
- }
- if ($save == ADODB_FETCH_NUM) $retarr[] = $fld;
- else $retarr[strtoupper($fld->name)] = $fld;
+ }
+
+ if ($save == ADODB_FETCH_NUM) {
+ $retarr[] = $fld;
+ } else {
+ $retarr[strtoupper($fld->name)] = $fld;
+ }
$rs->MoveNext();
}
+
$rs->Close();
return $retarr;
- }
- return false;
}
// returns true or false
@@ -533,11 +526,12 @@ class ADORecordSet_mysql extends ADORecordSet{
{
case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
- default:
case ADODB_FETCH_DEFAULT:
- case ADODB_FETCH_BOTH:$this->fetchMode = MYSQL_BOTH; break;
+ case ADODB_FETCH_BOTH:
+ default:
+ $this->fetchMode = MYSQL_BOTH; break;
}
-
+ $this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID);
}
@@ -688,17 +682,18 @@ class ADORecordSet_ext_mysql extends ADORecordSet_mysql {
{
case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
- default:
case ADODB_FETCH_DEFAULT:
- case ADODB_FETCH_BOTH:$this->fetchMode = MYSQL_BOTH; break;
+ case ADODB_FETCH_BOTH:
+ default:
+ $this->fetchMode = MYSQL_BOTH; break;
}
-
- $this->ADORecordSet($queryID);
+ $this->adodbFetchMode = $mode;
+ $this->ADORecordSet($queryID);
}
function MoveNext()
{
- return adodb_movenext($this);
+ return @adodb_movenext($this);
}
}
diff --git a/lib/adodb/drivers/adodb-mysqli.inc.php b/lib/adodb/drivers/adodb-mysqli.inc.php
index 5d689191011..c5bdf13b57c 100644
--- a/lib/adodb/drivers/adodb-mysqli.inc.php
+++ b/lib/adodb/drivers/adodb-mysqli.inc.php
@@ -1,6 +1,6 @@
forceNewConnect = true;
- $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
+ return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
}
function IfNull( $field, $ifNull )
@@ -176,7 +179,6 @@ class ADODB_mysqli extends ADOConnection {
function _insertid()
{
-// $this->_connectionID = $this->mysqli_resolve_link($this->_connectionID);
$result = @mysqli_insert_id($this->_connectionID);
if ($result == -1){
if ($this->debug) ADOConnection::outp("mysqli_insert_id() failed : " . $this->ErrorMsg());
@@ -187,7 +189,6 @@ class ADODB_mysqli extends ADOConnection {
// Only works for INSERT, UPDATE and DELETE query's
function _affectedrows()
{
- // $this->_connectionID = $this->mysqli_resolve_link($this->_connectionID);
$result = @mysqli_affected_rows($this->_connectionID);
if ($result == -1) {
if ($this->debug) ADOConnection::outp("mysqli_affected_rows() failed : " . $this->ErrorMsg());
@@ -235,62 +236,62 @@ class ADODB_mysqli extends ADOConnection {
}
function &MetaDatabases()
- {
- $query = "SHOW DATABASES";
- $ret =& $this->Execute($query);
+ {
+ $query = "SHOW DATABASES";
+ $ret =& $this->Execute($query);
return $ret;
- }
+ }
function &MetaIndexes ($table, $primary = FALSE)
{
- // save old fetch mode
- global $ADODB_FETCH_MODE;
-
- $save = $ADODB_FETCH_MODE;
- $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
- if ($this->fetchMode !== FALSE) {
- $savem = $this->SetFetchMode(FALSE);
- }
-
- // get index details
- $rs = $this->Execute(sprintf('SHOW INDEXES FROM %s',$table));
-
- // restore fetchmode
- if (isset($savem)) {
- $this->SetFetchMode($savem);
- }
- $ADODB_FETCH_MODE = $save;
-
- if (!is_object($rs)) {
- return FALSE;
- }
-
- $indexes = array ();
-
- // parse index data into array
- while ($row = $rs->FetchRow()) {
- if ($primary == FALSE AND $row[2] == 'PRIMARY') {
- continue;
- }
-
- if (!isset($indexes[$row[2]])) {
- $indexes[$row[2]] = array(
- 'unique' => ($row[1] == 0),
- 'columns' => array()
- );
- }
-
- $indexes[$row[2]]['columns'][$row[3] - 1] = $row[4];
- }
-
- // sort columns by order in the index
- foreach ( array_keys ($indexes) as $index )
- {
- ksort ($indexes[$index]['columns']);
- }
-
- return $indexes;
+ // save old fetch mode
+ global $ADODB_FETCH_MODE;
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
+
+ // get index details
+ $rs = $this->Execute(sprintf('SHOW INDEXES FROM %s',$table));
+
+ // restore fetchmode
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ }
+ $ADODB_FETCH_MODE = $save;
+
+ if (!is_object($rs)) {
+ return FALSE;
+ }
+
+ $indexes = array ();
+
+ // parse index data into array
+ while ($row = $rs->FetchRow()) {
+ if ($primary == FALSE AND $row[2] == 'PRIMARY') {
+ continue;
+ }
+
+ if (!isset($indexes[$row[2]])) {
+ $indexes[$row[2]] = array(
+ 'unique' => ($row[1] == 0),
+ 'columns' => array()
+ );
+ }
+
+ $indexes[$row[2]]['columns'][$row[3] - 1] = $row[4];
+ }
+
+ // sort columns by order in the index
+ foreach ( array_keys ($indexes) as $index )
+ {
+ ksort ($indexes[$index]['columns']);
+ }
+
+ return $indexes;
}
@@ -388,109 +389,65 @@ class ADODB_mysqli extends ADOConnection {
function &MetaColumns($table)
{
- if ($this->metaColumnsSQL) {
- global $ADODB_FETCH_MODE;
- $save = $ADODB_FETCH_MODE;
- $rs = false;
- switch($ADODB_FETCH_MODE)
- {
- case ADODB_FETCH_NUM:
- $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
- $rs = $this->Execute(sprintf($this->metaColumnsSQL,
- $table));
+ if (!$this->metaColumnsSQL)
+ return false;
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== false)
+ $savem = $this->SetFetchMode(false);
+ $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
+ if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
- if ($rs === false) break;
+ if (!is_object($rs))
+ return false;
+
$retarr = array();
- while (!$rs->EOF){
- $fld = new ADOFieldObject();
- $fld->name = $rs->fields[0];
- $fld->type = $rs->fields[1];
- // split type into type(length):
- if (preg_match("/^(.+)\((\d+)\)$/", $fld->type, $query_array))
- {
- $fld->type = $query_array[1];
- $fld->max_length = $query_array[2];
- }
- else
- {
- $fld->max_length = -1;
- }
- $fld->not_null = ($rs->fields[2] != 'YES');
- $fld->primary_key = ($rs->fields[3] == 'PRI');
- $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
- $fld->binary = (strpos($fld->type,'blob') !== false);
- if (!$fld->binary)
- {
- $d = $rs->fields[4];
- $d = $rs->fields['Default'];
- if ($d != "" && $d != "NULL")
- {
- $fld->has_default = true;
- $fld->default_value = $d;
- }
- else
- {
- $fld->has_default = false;
+ while (!$rs->EOF) {
+ $fld = new ADOFieldObject();
+ $fld->name = $rs->fields[0];
+ $type = $rs->fields[1];
+
+ // split type into type(length):
+ $fld->scale = null;
+ if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) {
+ $fld->type = $query_array[1];
+ $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
+ $fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1;
+ } elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) {
+ $fld->type = $query_array[1];
+ $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
+ } else {
+ $fld->type = $type;
+ $fld->max_length = -1;
}
- }
- $retarr[strtoupper($fld->name)] = $fld;
- $rs->MoveNext();
- }
- break;
- case ADODB_FETCH_ASSOC:
- case ADODB_FETCH_DEFAULT:
- case ADODB_FETCH_BOTH:
- $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
- $rs = $this->Execute(sprintf($this->metaColumnsSQL,
- $table));
- $ADODB_FETCH_MODE = $save;
- if ($rs === false) break;
- $retarr = array();
- while (!$rs->EOF){
- $fld = new ADOFieldObject();
- $fld->name = $rs->fields['Field'];
- $fld->type = $rs->fields['Type'];
-
- // split type into type(length):
- if (preg_match("/^(.+)\((\d+)\)$/", $fld->type, $query_array))
- {
- $fld->type = $query_array[1];
- $fld->max_length = $query_array[2];
- }
- else
- {
- $fld->max_length = -1;
- }
- $fld->not_null = ($rs->fields['Null'] != 'YES');
- $fld->primary_key = ($rs->fields['Key'] == 'PRI');
- $fld->auto_increment = (strpos($rs->fields['Extra'], 'auto_increment') !== false);
- $fld->binary = (strpos($fld->type,'blob') !== false);
- if (!$fld->binary)
- {
- $d = $rs->fields['Default'];
- if ($d != "" && $d != "NULL")
- {
- $fld->has_default = true;
- $fld->default_value = $d;
- }
- else
- {
- $fld->has_default = false;
+ $fld->not_null = ($rs->fields[2] != 'YES');
+ $fld->primary_key = ($rs->fields[3] == 'PRI');
+ $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
+ $fld->binary = (strpos($type,'blob') !== false);
+ $fld->unsigned = (strpos($type,'unsigned') !== false);
+
+ if (!$fld->binary) {
+ $d = $rs->fields[4];
+ if ($d != '' && $d != 'NULL') {
+ $fld->has_default = true;
+ $fld->default_value = $d;
+ } else {
+ $fld->has_default = false;
+ }
}
- }
- $retarr[strtoupper($fld->name)] = $fld;
- $rs->MoveNext();
+
+ if ($save == ADODB_FETCH_NUM) {
+ $retarr[] = $fld;
+ } else {
+ $retarr[strtoupper($fld->name)] = $fld;
+ }
+ $rs->MoveNext();
}
- break;
- default:
- }
-
- if ($rs === false) return false;
- $rs->Close();
- return $retarr;
- }
- return false;
+
+ $rs->Close();
+ return $retarr;
}
// returns true or false
@@ -644,7 +601,7 @@ class ADORecordSet_mysqli extends ADORecordSet{
$this->fetchMode = MYSQLI_BOTH;
break;
}
-
+ $this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID);
}
@@ -710,7 +667,7 @@ class ADORecordSet_mysqli extends ADORecordSet{
{
if ($this->EOF) return false;
$this->_currentRow++;
- $this->fields = mysqli_fetch_array($this->_queryID,$this->fetchMode);
+ $this->fields = @mysqli_fetch_array($this->_queryID,$this->fetchMode);
if (is_array($this->fields)) return true;
$this->EOF = true;
@@ -729,70 +686,132 @@ class ADORecordSet_mysqli extends ADORecordSet{
$this->_queryID = false;
}
+/*
+
+0 = MYSQLI_TYPE_DECIMAL
+1 = MYSQLI_TYPE_CHAR
+1 = MYSQLI_TYPE_TINY
+2 = MYSQLI_TYPE_SHORT
+3 = MYSQLI_TYPE_LONG
+4 = MYSQLI_TYPE_FLOAT
+5 = MYSQLI_TYPE_DOUBLE
+6 = MYSQLI_TYPE_NULL
+7 = MYSQLI_TYPE_TIMESTAMP
+8 = MYSQLI_TYPE_LONGLONG
+9 = MYSQLI_TYPE_INT24
+10 = MYSQLI_TYPE_DATE
+11 = MYSQLI_TYPE_TIME
+12 = MYSQLI_TYPE_DATETIME
+13 = MYSQLI_TYPE_YEAR
+14 = MYSQLI_TYPE_NEWDATE
+247 = MYSQLI_TYPE_ENUM
+248 = MYSQLI_TYPE_SET
+249 = MYSQLI_TYPE_TINY_BLOB
+250 = MYSQLI_TYPE_MEDIUM_BLOB
+251 = MYSQLI_TYPE_LONG_BLOB
+252 = MYSQLI_TYPE_BLOB
+253 = MYSQLI_TYPE_VAR_STRING
+254 = MYSQLI_TYPE_STRING
+255 = MYSQLI_TYPE_GEOMETRY
+*/
+
function MetaType($t, $len = -1, $fieldobj = false)
{
- if (is_object($t))
- {
- $fieldobj = $t;
- $t = $fieldobj->type;
- $len = $fieldobj->max_length;
- }
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
- $len = -1; // mysql max_length is not accurate
- switch (strtoupper($t)) {
- case 'STRING':
- case 'CHAR':
- case 'VARCHAR':
- case 'TINYBLOB':
- case 'TINYTEXT':
- case 'ENUM':
- case 'SET':
- if ($len <= $this->blobSize) return 'C';
-
- case 'TEXT':
- case 'LONGTEXT':
- case 'MEDIUMTEXT':
- return 'X';
-
- // php_mysql extension always returns 'blob' even if 'text'
- // so we have to check whether binary...
- case 'IMAGE':
- case 'LONGBLOB':
- case 'BLOB':
- case 'MEDIUMBLOB':
- return !empty($fieldobj->binary) ? 'B' : 'X';
- case 'YEAR':
- case 'DATE':
- return 'D';
- case 'TIME':
- case 'DATETIME':
- case 'TIMESTAMP': return 'T';
+ $len = -1; // mysql max_length is not accurate
+ switch (strtoupper($t)) {
+ /* case 'STRING':
+ case 'CHAR':
+ case 'VARCHAR':
+ case 'TINYBLOB':
+ case 'TINYTEXT':
+ case 'ENUM':
+ case 'SET': */
- case 'INT':
- case 'INTEGER':
- case 'BIGINT':
- case 'TINYINT':
- case 'MEDIUMINT':
- case 'SMALLINT':
-
- if (!empty($fieldobj->primary_key)) return 'R';
- else return 'I';
- // Added floating-point types
- // Maybe not necessery.
- case 'FLOAT':
- case 'DOUBLE':
- // case 'DOUBLE PRECISION':
- case 'DECIMAL':
- case 'DEC':
- case 'FIXED':
- default:
- return 'N';
- }
- }
+ case MYSQLI_TYPE_TINY_BLOB :
+ case MYSQLI_TYPE_CHAR :
+ case MYSQLI_TYPE_STRING :
+ case MYSQLI_TYPE_ENUM :
+ case MYSQLI_TYPE_SET :
+ case 253 :
+ if ($len <= $this->blobSize) return 'C';
+
+ /*case 'TEXT':
+ case 'LONGTEXT':
+ case 'MEDIUMTEXT':*/
+ return 'X';
+
+
+ // php_mysql extension always returns 'blob' even if 'text'
+ // so we have to check whether binary...
+ /*case 'IMAGE':
+ case 'LONGBLOB':
+ case 'BLOB':
+ case 'MEDIUMBLOB':*/
+
+ case MYSQLI_TYPE_BLOB :
+ case MYSQLI_TYPE_LONG_BLOB :
+ case MYSQLI_TYPE_MEDIUM_BLOB :
+
+ return !empty($fieldobj->binary) ? 'B' : 'X';
+ /*case 'YEAR':
+ case 'DATE': */
+ case MYSQLI_TYPE_DATE :
+ case MYSQLI_TYPE_YEAR :
+
+ return 'D';
+
+ /*case 'TIME':
+ case 'DATETIME':
+ case 'TIMESTAMP':*/
+
+ case MYSQLI_TYPE_DATETIME :
+ case MYSQLI_TYPE_NEWDATE :
+ case MYSQLI_TYPE_TIME :
+ case MYSQLI_TYPE_TIMESTAMP :
+
+ return 'T';
+
+ /*case 'INT':
+ case 'INTEGER':
+ case 'BIGINT':
+ case 'TINYINT':
+ case 'MEDIUMINT':
+ case 'SMALLINT':
+ */
+ case MYSQLI_TYPE_INT24 :
+ case MYSQLI_TYPE_LONG :
+ case MYSQLI_TYPE_LONGLONG :
+ case MYSQLI_TYPE_SHORT :
+ case MYSQLI_TYPE_TINY :
+
+ if (!empty($fieldobj->primary_key)) return 'R';
+
+ return 'I';
+
+ /*
+ // Added floating-point types
+ // Maybe not necessery.
+ case 'FLOAT':
+ case 'DOUBLE':
+ // case 'DOUBLE PRECISION':
+ case 'DECIMAL':
+ case 'DEC':
+ case 'FIXED':*/
+ default:
+ if (!is_numeric($t)) echo "--- Error in type matching $t -----
";
+ return 'N';
+ }
+ } // function
-}
+} // rs class
}
diff --git a/lib/adodb/drivers/adodb-mysqlt.inc.php b/lib/adodb/drivers/adodb-mysqlt.inc.php
index f7e2bfdd273..6c31418d811 100644
--- a/lib/adodb/drivers/adodb-mysqlt.inc.php
+++ b/lib/adodb/drivers/adodb-mysqlt.inc.php
@@ -1,7 +1,7 @@
fetchMode = MYSQL_NUM; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
- default:
+
case ADODB_FETCH_DEFAULT:
- case ADODB_FETCH_BOTH:$this->fetchMode = MYSQL_BOTH; break;
+ case ADODB_FETCH_BOTH:
+ default: $this->fetchMode = MYSQL_BOTH; break;
}
+ $this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID);
}
@@ -108,9 +110,11 @@ class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
{
case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
- default:
+
case ADODB_FETCH_DEFAULT:
- case ADODB_FETCH_BOTH:$this->fetchMode = MYSQL_BOTH; break;
+ case ADODB_FETCH_BOTH:
+ default:
+ $this->fetchMode = MYSQL_BOTH; break;
}
$this->ADORecordSet($queryID);
diff --git a/lib/adodb/drivers/adodb-netezza.inc.php b/lib/adodb/drivers/adodb-netezza.inc.php
index 8c2867f4046..1bd7906183e 100644
--- a/lib/adodb/drivers/adodb-netezza.inc.php
+++ b/lib/adodb/drivers/adodb-netezza.inc.php
@@ -1,6 +1,6 @@
fetchMode = PGSQL_NUM; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = PGSQL_ASSOC; break;
- default:
+
case ADODB_FETCH_DEFAULT:
- case ADODB_FETCH_BOTH:$this->fetchMode = PGSQL_BOTH; break;
+ case ADODB_FETCH_BOTH:
+ default: $this->fetchMode = PGSQL_BOTH; break;
}
+ $this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID);
}
diff --git a/lib/adodb/drivers/adodb-oci8.inc.php b/lib/adodb/drivers/adodb-oci8.inc.php
index ded925cd4a9..f1f913c408b 100644
--- a/lib/adodb/drivers/adodb-oci8.inc.php
+++ b/lib/adodb/drivers/adodb-oci8.inc.php
@@ -1,7 +1,7 @@
fetchMode !== false) $savem = $this->SetFetchMode(false);
@@ -107,7 +108,9 @@ class ADODB_oci8 extends ADOConnection {
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
- if (!$rs) return false;
+ if (!$rs) {
+ return $false;
+ }
$retarr = array();
while (!$rs->EOF) { //print_r($rs->fields);
$fld = new ADOFieldObject();
@@ -128,7 +131,7 @@ class ADODB_oci8 extends ADOConnection {
$rs->MoveNext();
}
$rs->Close();
- return $retarr;
+ return (empty($retarr)) ? $false : $retarr;
}
function Time()
@@ -203,12 +206,23 @@ NATSOFT.DOMAIN =
//if ($argHostname) print "Connect: 1st argument should be left blank for $this->databaseType
";
if ($mode==1) {
- $this->_connectionID = OCIPLogon($argUsername,$argPassword, $argDatabasename);
+ $this->_connectionID = ($this->charSet) ?
+ OCIPLogon($argUsername,$argPassword, $argDatabasename)
+ :
+ OCIPLogon($argUsername,$argPassword, $argDatabasename, $this->charSet)
+ ;
if ($this->_connectionID && $this->autoRollback) OCIrollback($this->_connectionID);
} else if ($mode==2) {
- $this->_connectionID = OCINLogon($argUsername,$argPassword, $argDatabasename);
+ $this->_connectionID = ($this->charSet) ?
+ OCINLogon($argUsername,$argPassword, $argDatabasename)
+ :
+ OCINLogon($argUsername,$argPassword, $argDatabasename, $this->charSet);
+
} else {
- $this->_connectionID = OCILogon($argUsername,$argPassword, $argDatabasename);
+ $this->_connectionID = ($this->charSet) ?
+ OCILogon($argUsername,$argPassword, $argDatabasename)
+ :
+ OCILogon($argUsername,$argPassword, $argDatabasename,$this->charSet);
}
if ($this->_connectionID === false) return false;
if ($this->_initdate) {
@@ -291,6 +305,73 @@ NATSOFT.DOMAIN =
return $ret;
}
+ // Mark Newnham
+ function &MetaIndexes ($table, $primary = FALSE, $owner=false)
+ {
+ // save old fetch mode
+ global $ADODB_FETCH_MODE;
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
+
+ // get index details
+ $table = strtoupper($table);
+
+ // get Primary index
+ $primary_key = '';
+
+ $false = false;
+ $rs = $this->Execute(sprintf("SELECT * FROM ALL_CONSTRAINTS WHERE UPPER(TABLE_NAME)='%s' AND CONSTRAINT_TYPE='P'",$table));
+ if ($row = $rs->FetchRow())
+ $primary_key = $row[1]; //constraint_name
+
+ if ($primary==TRUE && $primary_key=='') {
+ if (isset($savem))
+ $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ return $false; //There is no primary key
+ }
+
+ $rs = $this->Execute(sprintf("SELECT ALL_INDEXES.INDEX_NAME, ALL_INDEXES.UNIQUENESS, ALL_IND_COLUMNS.COLUMN_POSITION, ALL_IND_COLUMNS.COLUMN_NAME FROM ALL_INDEXES,ALL_IND_COLUMNS WHERE UPPER(ALL_INDEXES.TABLE_NAME)='%s' AND ALL_IND_COLUMNS.INDEX_NAME=ALL_INDEXES.INDEX_NAME",$table));
+
+
+ if (!is_object($rs)) {
+ if (isset($savem))
+ $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ return $false;
+ }
+
+ $indexes = array ();
+ // parse index data into array
+
+ while ($row = $rs->FetchRow()) {
+ if ($primary && $row[0] != $primary_key) continue;
+ if (!isset($indexes[$row[0]])) {
+ $indexes[$row[0]] = array(
+ 'unique' => ($row[1] == 'UNIQUE'),
+ 'columns' => array()
+ );
+ }
+ $indexes[$row[0]]['columns'][$row[2] - 1] = $row[3];
+ }
+
+ // sort columns by order in the index
+ foreach ( array_keys ($indexes) as $index ) {
+ ksort ($indexes[$index]['columns']);
+ }
+
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ }
+ return $indexes;
+ }
+
function BeginTrans()
{
if ($this->transOff) return true;
@@ -457,9 +538,9 @@ NATSOFT.DOMAIN =
if ($offset > 0) $nrows += $offset;
//$inputarr['adodb_rownum'] = $nrows;
if ($this->databaseType == 'oci8po') {
- $sql = "select * from ($sql) where rownum <= ?";
+ $sql = "select * from (".$sql.") where rownum <= ?";
} else {
- $sql = "select * from ($sql) where rownum <= :adodb_offset";
+ $sql = "select * from (".$sql.") where rownum <= :adodb_offset";
}
$inputarr['adodb_offset'] = $nrows;
$nrows = -1;
@@ -473,10 +554,13 @@ NATSOFT.DOMAIN =
// Algorithm by Tomas V V Cox, from PEAR DB oci8.php
// Let Oracle return the name of the columns
- $q_fields = "SELECT * FROM ($sql) WHERE NULL = NULL";
- if (!$stmt = OCIParse($this->_connectionID, $q_fields)) {
- return false;
- }
+ $q_fields = "SELECT * FROM (".$sql.") WHERE NULL = NULL";
+
+ $false = false;
+ if (! $stmt_arr = $this->Prepare($q_fields)) {
+ return $false;
+ }
+ $stmt = $stmt_arr[1];
if (is_array($inputarr)) {
foreach($inputarr as $k => $v) {
@@ -499,7 +583,7 @@ NATSOFT.DOMAIN =
if (!OCIExecute($stmt, OCI_DEFAULT)) {
OCIFreeStatement($stmt);
- return false;
+ return $false;
}
$ncols = OCINumCols($stmt);
@@ -575,7 +659,7 @@ NATSOFT.DOMAIN =
if ($this->session_sharing_force_blob) $this->Execute('ALTER SESSION SET CURSOR_SHARING=EXACT');
$commit = $this->autoCommit;
if ($commit) $this->BeginTrans();
- $rs = $this->_Execute($sql,$arr);
+ $rs = $this->Execute($sql,$arr);
if ($rez = !empty($rs)) $desc->save($val);
$desc->free();
if ($commit) $this->CommitTrans();
@@ -630,16 +714,15 @@ NATSOFT.DOMAIN =
$BINDNUM += 1;
- if (@OCIStatementType($stmt) == 'BEGIN') {
+ $sttype = @OCIStatementType($stmt);
+ if ($sttype == 'BEGIN' || $sttype == 'DECLARE') {
return array($sql,$stmt,0,$BINDNUM, ($cursor) ? OCINewCursor($this->_connectionID) : false);
- }
-
+ }
return array($sql,$stmt,0,$BINDNUM);
}
/*
- Call an oracle stored procedure and return a cursor variable.
- Convert the cursor variable into a recordset.
+ Call an oracle stored procedure and returns a cursor variable as a recordset.
Concept by Robert Tuttle robert@ud.com
Example:
@@ -654,17 +737,24 @@ NATSOFT.DOMAIN =
*/
function &ExecuteCursor($sql,$cursorName='rs',$params=false)
{
- $stmt = ADODB_oci8::Prepare($sql,true); # true to allocate OCINewCursor
-
+ if (is_array($sql)) $stmt = $sql;
+ else $stmt = ADODB_oci8::Prepare($sql,true); # true to allocate OCINewCursor
+
if (is_array($stmt) && sizeof($stmt) >= 5) {
+ $hasref = true;
$this->Parameter($stmt, $ignoreCur, $cursorName, false, -1, OCI_B_CURSOR);
if ($params) {
foreach($params as $k => $v) {
$this->Parameter($stmt,$params[$k], $k);
}
}
- }
- return $this->Execute($stmt);
+ } else
+ $hasref = false;
+
+ $rs =& $this->Execute($stmt);
+ if ($rs->databaseType == 'array') OCIFreeCursor($stmt[4]);
+ else if ($hasref) $rs->_refcursor = $stmt[4];
+ return $rs;
}
/*
@@ -715,25 +805,26 @@ NATSOFT.DOMAIN =
ADOConnection::outp("Bind : name = $name");
}
//we have to create a new Descriptor here
- $numlob = count($this -> _refLOBs);
- $this -> _refLOBs[$numlob]['LOB'] = OCINewDescriptor($this->_connectionID, oci_lob_desc($type));
- $this -> _refLOBs[$numlob]['TYPE'] = $isOutput;
+ $numlob = count($this->_refLOBs);
+ $this->_refLOBs[$numlob]['LOB'] = OCINewDescriptor($this->_connectionID, oci_lob_desc($type));
+ $this->_refLOBs[$numlob]['TYPE'] = $isOutput;
- $tmp = &$this -> _refLOBs[$numlob]['LOB'];
+ $tmp = &$this->_refLOBs[$numlob]['LOB'];
$rez = OCIBindByName($stmt[1], ":".$name, $tmp, -1, $type);
if ($this->debug) {
- ADOConnection::outp("Bind : descriptor has been allocated, var binded");
+ ADOConnection::outp("Bind : descriptor has been allocated, var (".$name.") binded");
}
// if type is input then write data to lob now
if ($isOutput == false) {
- $var = $this -> BlobEncode($var);
- $tmp -> WriteTemporary($var);
+ $var = $this->BlobEncode($var);
+ $tmp->WriteTemporary($var);
+ $this->_refLOBs[$numlob]['VAR'] = &$var;
if ($this->debug) {
ADOConnection::outp("Bind : LOB has been written to temp");
}
} else {
- $this -> _refLOBs[$numlob]['VAR'] = &$var;
+ $this->_refLOBs[$numlob]['VAR'] = &$var;
}
$rez = $tmp;
} else {
@@ -790,7 +881,7 @@ NATSOFT.DOMAIN =
3. $db->execute('insert into table (a,b,c) values (:a,:b,:c)',array('a'=>1,'b'=>2,'c'=>3));
4. $db->prepare('insert into table (a,b,c) values (:0,:1,:2)');
- $db->$bind($stmt,1); $db->bind($stmt,2); $db->bind($stmt,3);
+ $db->bind($stmt,1); $db->bind($stmt,2); $db->bind($stmt,3);
$db->execute($stmt);
*/
function _query($sql,$inputarr)
@@ -811,7 +902,7 @@ NATSOFT.DOMAIN =
$bindarr = array();
foreach($inputarr as $k => $v) {
$bindarr[$k] = $v;
- OCIBindByName($stmt,":$k",$bindarr[$k],4000);
+ OCIBindByName($stmt,":$k",$bindarr[$k],is_string($v) && strlen($v)>4000 ? -1 : 4000);
}
$this->_bind[$bindpos] = &$bindarr;
}
@@ -833,7 +924,7 @@ NATSOFT.DOMAIN =
else
OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1],$v[2]);
- if ($this->debug==99) echo "name=:$k",' var='.$inputarr[$k][0],' len='.$v[1],' type='.$v[2],' ';
+ if ($this->debug==99) echo "name=:$k",' var='.$inputarr[$k][0],' len='.$v[1],' type='.$v[2],' ';
} else {
$len = -1;
if ($v === ' ') $len = 1;
@@ -856,20 +947,26 @@ NATSOFT.DOMAIN =
if ($this -> _refLOBs[$key]['TYPE'] == true) {
$tmp = $this -> _refLOBs[$key]['LOB'] -> load();
if ($this -> debug) {
- ADOConnection::outp("OUT LOB : LOB has been loaded. ");
+ ADOConnection::outp("OUT LOB : LOB has been loaded. ");
}
//$_GLOBALS[$this -> _refLOBs[$key]['VAR']] = $tmp;
$this -> _refLOBs[$key]['VAR'] = $tmp;
- }
- $this -> _refLOBs[$key]['LOB'] -> free();
- unset($this -> _refLOBs[$key]);
+ } else {
+ $this->_refLOBs[$key]['LOB']->save($this->_refLOBs[$key]['VAR']);
+ $this -> _refLOBs[$key]['LOB']->free();
+ unset($this -> _refLOBs[$key]);
+ if ($this->debug) {
+ ADOConnection::outp("IN LOB : LOB has been saved. ");
+ }
+ }
}
}
switch (@OCIStatementType($stmt)) {
case "SELECT":
return $stmt;
-
+
+ case 'DECLARE':
case "BEGIN":
if (is_array($sql) && !empty($sql[4])) {
$cursor = $sql[4];
@@ -1038,6 +1135,7 @@ class ADORecordset_oci8 extends ADORecordSet {
var $databaseType = 'oci8';
var $bind=false;
var $_fieldobjs;
+
//var $_arr = false;
function ADORecordset_oci8($queryID,$mode=false)
@@ -1048,13 +1146,15 @@ class ADORecordset_oci8 extends ADORecordSet {
}
switch ($mode)
{
- default:
- case ADODB_FETCH_NUM: $this->fetchMode = OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;
case ADODB_FETCH_DEFAULT:
case ADODB_FETCH_BOTH:$this->fetchMode = OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;
+ case ADODB_FETCH_NUM:
+ default:
+ $this->fetchMode = OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;
}
-
+
+ $this->adodbFetchMode = $mode;
$this->_queryID = $queryID;
}
@@ -1213,7 +1313,11 @@ class ADORecordset_oci8 extends ADORecordSet {
function _close()
{
if ($this->connection->_stmt === $this->_queryID) $this->connection->_stmt = false;
- OCIFreeStatement($this->_queryID);
+ if (!empty($this->_refcursor)) {
+ OCIFreeCursor($this->_refcursor);
+ $this->_refcursor = false;
+ }
+ @OCIFreeStatement($this->_queryID);
$this->_queryID = false;
}
@@ -1272,13 +1376,13 @@ class ADORecordSet_ext_oci8 extends ADORecordSet_oci8 {
}
switch ($mode)
{
- default:
- case ADODB_FETCH_NUM: $this->fetchMode = OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;
case ADODB_FETCH_DEFAULT:
case ADODB_FETCH_BOTH:$this->fetchMode = OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;
+ case ADODB_FETCH_NUM:
+ default: $this->fetchMode = OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;
}
-
+ $this->adodbFetchMode = $mode;
$this->_queryID = $queryID;
}
diff --git a/lib/adodb/drivers/adodb-oci805.inc.php b/lib/adodb/drivers/adodb-oci805.inc.php
index 5790fbefa30..44ea8914aa3 100644
--- a/lib/adodb/drivers/adodb-oci805.inc.php
+++ b/lib/adodb/drivers/adodb-oci805.inc.php
@@ -1,6 +1,6 @@
_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('odbc_connect')) return null;
+
+ if ($this->debug && $argDatabasename && $this->databaseType != 'vfp') {
+ ADOConnection::outp("For odbc Connect(), $argDatabasename is not used. Place dsn in 1st parameter.");
+ }
+ if (isset($php_errormsg)) $php_errormsg = '';
+ if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword);
+ else $this->_connectionID = odbc_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('odbc_connect')) return null;
+
+ if (isset($php_errormsg)) $php_errormsg = '';
+ $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
+ if ($this->debug && $argDatabasename) {
+ ADOConnection::outp("For odbc PConnect(), $argDatabasename is not used. Place dsn in 1st parameter.");
+ }
+ // print "dsn=$argDSN u=$argUsername p=$argPassword "; flush();
+ if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword);
+ else $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,$this->curmode);
+
+ $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
+ if ($this->_connectionID && $this->autoRollback) @odbc_rollback($this->_connectionID);
+ if (isset($this->connectStmt)) $this->Execute($this->connectStmt);
+
+ return $this->_connectionID != false;
+ }
+
+
function ServerInfo()
{
@@ -156,48 +199,6 @@ class ADODB_odbc extends ADOConnection {
}
- // returns true or false
- function _connect($argDSN, $argUsername, $argPassword, $argDatabasename)
- {
- global $php_errormsg;
-
- if (!function_exists('odbc_connect')) return null;
-
- if ($this->debug && $argDatabasename && $this->databaseType != 'vfp') {
- ADOConnection::outp("For odbc Connect(), $argDatabasename is not used. Place dsn in 1st parameter.");
- }
- if (isset($php_errormsg)) $php_errormsg = '';
- if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword);
- else $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,$this->curmode);
- $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
- if (isset($this->connectStmt)) $this->Execute($this->connectStmt);
-
- //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
- return $this->_connectionID != false;
- }
-
- // returns true or false
- function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
- {
- global $php_errormsg;
-
- if (!function_exists('odbc_connect')) return null;
-
- if (isset($php_errormsg)) $php_errormsg = '';
- $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
- if ($this->debug && $argDatabasename) {
- ADOConnection::outp("For odbc PConnect(), $argDatabasename is not used. Place dsn in 1st parameter.");
- }
- // print "dsn=$argDSN u=$argUsername p=$argPassword "; flush();
- if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword);
- else $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,$this->curmode);
-
- $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
- if ($this->_connectionID && $this->autoRollback) @odbc_rollback($this->_connectionID);
- if (isset($this->connectStmt)) $this->Execute($this->connectStmt);
-
- return $this->_connectionID != false;
- }
function BeginTrans()
{
@@ -274,8 +275,10 @@ class ADODB_odbc extends ADOConnection {
$rs = new ADORecordSet_odbc($qid);
$ADODB_FETCH_MODE = $savem;
- if (!$rs) return false;
-
+ if (!$rs) {
+ $false = false;
+ return $false;
+ }
$rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
$arr =& $rs->GetArray();
@@ -300,6 +303,7 @@ class ADODB_odbc extends ADOConnection {
}
/*
+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
@@ -315,6 +319,7 @@ class ADODB_odbc extends ADOConnection {
#endif
#define SQL_VARCHAR 12
+
/ One-parameter shortcuts for date/time data types /
#if (ODBCVER >= 0x0300)
#define SQL_TYPE_DATE 91
@@ -340,13 +345,16 @@ class ADODB_odbc extends ADOConnection {
case -4: //image
return 'B';
+ case 9:
case 91:
- case 11:
return 'D';
-
+
+ case 10:
+ case 11:
case 92:
case 93:
- case 9: return 'T';
+ return 'T';
+
case 4:
case 5:
case -6:
@@ -366,6 +374,7 @@ class ADODB_odbc extends ADOConnection {
{
global $ADODB_FETCH_MODE;
+ $false = false;
if ($this->uCaseTables) $table = strtoupper($table);
$schema = '';
$this->_findschema($table,$schema);
@@ -411,15 +420,15 @@ class ADODB_odbc extends ADOConnection {
if (empty($qid)) $qid = odbc_columns($this->_connectionID);
break;
}
- if (empty($qid)) return false;
+ if (empty($qid)) return $false;
- $rs = new ADORecordSet_odbc($qid);
+ $rs =& new ADORecordSet_odbc($qid);
$ADODB_FETCH_MODE = $savem;
- if (!$rs) return false;
-
+ if (!$rs) return $false;
$rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
$rs->_fetch();
+
$retarr = array();
/*
@@ -438,8 +447,8 @@ class ADODB_odbc extends ADOConnection {
11 REMARKS
*/
while (!$rs->EOF) {
- //adodb_pr($rs->fields);
- if (strtoupper($rs->fields[2]) == $table && (!$schema || strtoupper($rs->fields[1]) == $schema)) {
+ // 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]);
@@ -464,7 +473,7 @@ class ADODB_odbc extends ADOConnection {
}
$rs->Close(); //-- crashes 4.03pl1 -- why?
- return $retarr;
+ return empty($retarr) ? $false : $retarr;
}
function Prepare($sql)
@@ -681,11 +690,13 @@ class ADORecordSet_odbc extends ADORecordSet {
{
if ($this->_numOfRows != 0 && !$this->EOF) {
$this->_currentRow++;
- $row = 0;
+
if ($this->_has_stupid_odbc_fetch_api_change)
$rez = @odbc_fetch_into($this->_queryID,$this->fields);
- else
+ else {
+ $row = 0;
$rez = @odbc_fetch_into($this->_queryID,$row,$this->fields);
+ }
if ($rez) {
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
@@ -700,12 +711,13 @@ class ADORecordSet_odbc extends ADORecordSet {
function _fetch()
{
- $row = 0;
+
if ($this->_has_stupid_odbc_fetch_api_change)
$rez = @odbc_fetch_into($this->_queryID,$this->fields,$row);
- else
+ else {
+ $row = 0;
$rez = @odbc_fetch_into($this->_queryID,$row,$this->fields);
-
+ }
if ($rez) {
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
diff --git a/lib/adodb/drivers/adodb-odbc_mssql.inc.php b/lib/adodb/drivers/adodb-odbc_mssql.inc.php
index abb92fc8bc1..5570c4ffdf8 100644
--- a/lib/adodb/drivers/adodb-odbc_mssql.inc.php
+++ b/lib/adodb/drivers/adodb-odbc_mssql.inc.php
@@ -1,6 +1,6 @@
ADODB_odbc();
- $this->curmode = SQL_CUR_USE_ODBC;
+ //$this->curmode = SQL_CUR_USE_ODBC;
}
// crashes php...
diff --git a/lib/adodb/drivers/adodb-odbc_oracle.inc.php b/lib/adodb/drivers/adodb-odbc_oracle.inc.php
index 90bfe5a7740..6df3b3c4665 100644
--- a/lib/adodb/drivers/adodb-odbc_oracle.inc.php
+++ b/lib/adodb/drivers/adodb-odbc_oracle.inc.php
@@ -1,6 +1,6 @@
metaTablesSQL) {
- $rs = $this->Execute($this->metaTablesSQL);
- if ($rs === false) return false;
- $arr = $rs->GetArray();
- $arr2 = array();
- for ($i=0; $i < sizeof($arr); $i++) {
- $arr2[] = $arr[$i][0];
- }
- $rs->Close();
- return $arr2;
+ $false = false;
+ $rs = $this->Execute($this->metaTablesSQL);
+ if ($rs === false) return $false;
+ $arr = $rs->GetArray();
+ $arr2 = array();
+ for ($i=0; $i < sizeof($arr); $i++) {
+ $arr2[] = $arr[$i][0];
}
- return false;
+ $rs->Close();
+ return $arr2;
}
function &MetaColumns($table)
{
- if (!empty($this->metaColumnsSQL)) {
- $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table)));
- if ($rs === false) return false;
-
- $retarr = array();
- while (!$rs->EOF) { //print_r($rs->fields);
- $fld = new ADOFieldObject();
- $fld->name = $rs->fields[0];
- $fld->type = $rs->fields[1];
- $fld->max_length = $rs->fields[2];
-
-
- if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
- else $retarr[strtoupper($fld->name)] = $fld;
-
- $rs->MoveNext();
- }
- $rs->Close();
- return $retarr;
+ $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table)));
+ if ($rs === false) {
+ $false = false;
+ return $false;
}
- return false;
+ $retarr = array();
+ while (!$rs->EOF) { //print_r($rs->fields);
+ $fld = new ADOFieldObject();
+ $fld->name = $rs->fields[0];
+ $fld->type = $rs->fields[1];
+ $fld->max_length = $rs->fields[2];
+
+
+ if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
+ else $retarr[strtoupper($fld->name)] = $fld;
+
+ $rs->MoveNext();
+ }
+ $rs->Close();
+ return $retarr;
}
// returns true or false
diff --git a/lib/adodb/drivers/adodb-odbtp.inc.php b/lib/adodb/drivers/adodb-odbtp.inc.php
index 62dc01bc1a4..e4c54ae8915 100644
--- a/lib/adodb/drivers/adodb-odbtp.inc.php
+++ b/lib/adodb/drivers/adodb-odbtp.inc.php
@@ -1,6 +1,6 @@
odbc_driver == ODB_DRIVER_FOXPRO ) {
+ if( $this->odbc_driver == ODB_DRIVER_FOXPRO) {
$path = @odbtp_get_attr( ODB_ATTR_DATABASENAME, $this->_connectionID );
//if using vfp dbc file
if( !strcasecmp(strrchr($path, '.'), '.dbc') )
@@ -150,16 +150,31 @@ class ADODB_odbtp extends ADOConnection{
function _connect($HostOrInterface, $UserOrDSN='', $argPassword='', $argDatabase='')
{
$this->_connectionID = @odbtp_connect($HostOrInterface,$UserOrDSN,$argPassword,$argDatabase);
- if ($this->_connectionID === false)
- {
+ if ($this->_connectionID === false) {
$this->_errorMsg = $this->ErrorMsg() ;
return false;
}
+ if ($this->_dontPoolDBC) {
+ if (function_exists('odbtp_dont_pool_dbc'))
+ @odbtp_dont_pool_dbc($this->_connectionID);
+ }
+ else {
+ $this->_dontPoolDBC = true;
+ }
$this->odbc_driver = @odbtp_get_attr(ODB_ATTR_DRIVER, $this->_connectionID);
+ $dbms = strtolower(@odbtp_get_attr(ODB_ATTR_DBMSNAME, $this->_connectionID));
+ $this->odbc_name = $dbms;
+
+ // Account for inconsistent DBMS names
+ if( $this->odbc_driver == ODB_DRIVER_ORACLE )
+ $dbms = 'oracle';
+ else if( $this->odbc_driver == ODB_DRIVER_SYBASE )
+ $dbms = 'sybase';
- // Set driver specific attributes
- switch( $this->odbc_driver ) {
- case ODB_DRIVER_MSSQL:
+ // Set DBMS specific attributes
+ switch( $dbms ) {
+ case 'microsoft sql server':
+ $this->databaseType = 'odbtp_mssql';
$this->fmtDate = "'Y-m-d'";
$this->fmtTimeStamp = "'Y-m-d h:i:sA'";
$this->sysDate = 'convert(datetime,convert(char,GetDate(),102),102)';
@@ -176,8 +191,10 @@ class ADODB_odbtp extends ADOConnection{
$this->length = 'len';
$this->identitySQL = 'select @@IDENTITY';
$this->metaDatabasesSQL = "select name from master..sysdatabases where name <> 'master'";
+ $this->_canPrepareSP = true;
break;
- case ODB_DRIVER_JET:
+ case 'access':
+ $this->databaseType = 'odbtp_access';
$this->fmtDate = "#Y-m-d#";
$this->fmtTimeStamp = "#Y-m-d h:i:sA#";
$this->sysDate = "FORMAT(NOW,'yyyy-mm-dd')";
@@ -185,24 +202,22 @@ class ADODB_odbtp extends ADOConnection{
$this->hasTop = 'top';
$this->hasTransactions = false;
$this->_canPrepareSP = true; // For MS Access only.
-
- // Can't rebind ODB_CHAR to ODB_WCHAR if row cache enabled.
- if ($this->_useUnicodeSQL)
- odbtp_use_row_cache($this->_connectionID, FALSE, 0);
break;
- case ODB_DRIVER_FOXPRO:
+ case 'visual foxpro':
+ $this->databaseType = 'odbtp_vfp';
$this->fmtDate = "{^Y-m-d}";
$this->fmtTimeStamp = "{^Y-m-d, h:i:sA}";
$this->sysDate = 'date()';
$this->sysTimeStamp = 'datetime()';
$this->ansiOuter = true;
$this->hasTop = 'top';
- $this->hasTransactions = false;
+ $this->hasTransactions = false;
$this->replaceQuote = "'+chr(39)+'";
$this->true = '.T.';
$this->false = '.F.';
break;
- case ODB_DRIVER_ORACLE:
+ case 'oracle':
+ $this->databaseType = 'odbtp_oci8';
$this->fmtDate = "'Y-m-d 00:00:00'";
$this->fmtTimeStamp = "'Y-m-d h:i:sA'";
$this->sysDate = 'TRUNC(SYSDATE)';
@@ -211,7 +226,8 @@ class ADODB_odbtp extends ADOConnection{
$this->_bindInputArray = true;
$this->concat_operator = '||';
break;
- case ODB_DRIVER_SYBASE:
+ case 'sybase':
+ $this->databaseType = 'odbtp_sybase';
$this->fmtDate = "'Y-m-d'";
$this->fmtTimeStamp = "'Y-m-d H:i:s'";
$this->sysDate = 'GetDate()';
@@ -223,22 +239,26 @@ class ADODB_odbtp extends ADOConnection{
$this->identitySQL = 'select @@IDENTITY';
break;
default:
+ $this->databaseType = 'odbtp';
if( @odbtp_get_attr(ODB_ATTR_TXNCAPABLE, $this->_connectionID) )
- $this->hasTransactions = true;
+ $this->hasTransactions = true;
else
$this->hasTransactions = false;
}
@odbtp_set_attr(ODB_ATTR_FULLCOLINFO, TRUE, $this->_connectionID );
+
if ($this->_useUnicodeSQL )
@odbtp_set_attr(ODB_ATTR_UNICODESQL, TRUE, $this->_connectionID);
+
return true;
}
-
+
function _pconnect($HostOrInterface, $UserOrDSN='', $argPassword='', $argDatabase='')
{
+ $this->_dontPoolDBC = false;
return $this->_connect($HostOrInterface, $UserOrDSN, $argPassword, $argDatabase);
}
-
+
function SelectDB($dbName)
{
if (!@odbtp_select_db($dbName, $this->_connectionID)) {
@@ -254,7 +274,11 @@ class ADODB_odbtp extends ADOConnection{
$savem = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== false) $savefm = $this->SetFetchMode(false);
+
$arr =& $this->GetArray("||SQLTables||||$ttype");
+
+ if (isset($savefm)) $this->SetFetchMode($savefm);
$ADODB_FETCH_MODE = $savem;
$arr2 = array();
@@ -276,11 +300,17 @@ class ADODB_odbtp extends ADOConnection{
$savem = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== false) $savefm = $this->SetFetchMode(false);
+
$rs = $this->Execute( "||SQLColumns||$schema|$table" );
+
+ if (isset($savefm)) $this->SetFetchMode($savefm);
$ADODB_FETCH_MODE = $savem;
- if (!$rs) return false;
-
+ if (!$rs || $rs->EOF) {
+ $false = false;
+ return $false;
+ }
while (!$rs->EOF) {
//print_r($rs->fields);
if (strtoupper($rs->fields[2]) == $table) {
@@ -299,7 +329,7 @@ class ADODB_odbtp extends ADOConnection{
break;
$rs->MoveNext();
}
- $rs->Close();
+ $rs->Close();
return $retarr;
}
@@ -335,8 +365,11 @@ class ADODB_odbtp extends ADOConnection{
//print_r($constr);
$arr[$constr[11]][$constr[2]][] = $constr[7].'='.$constr[3];
}
- if (!$arr) return false;
-
+ if (!$arr) {
+ $false = false;
+ return $false;
+ }
+
$arr2 = array();
foreach($arr as $k => $v) {
@@ -353,10 +386,14 @@ class ADODB_odbtp extends ADOConnection{
if (!$this->hasTransactions) return false;
if ($this->transOff) return true;
$this->transCnt += 1;
- $this->_autocommit = false;
- $rs = @odbtp_set_attr(ODB_ATTR_TRANSACTIONS,ODB_TXN_READUNCOMMITTED,$this->_connectionID);
+ $this->autoCommit = false;
+ if (defined('ODB_TXN_DEFAULT'))
+ $txn = ODB_TXN_DEFAULT;
+ else
+ $txn = ODB_TXN_READUNCOMMITTED;
+ $rs = @odbtp_set_attr(ODB_ATTR_TRANSACTIONS,$txn,$this->_connectionID);
if(!$rs) return false;
- else return true;
+ return true;
}
function CommitTrans($ok=true)
@@ -364,8 +401,8 @@ class ADODB_odbtp extends ADOConnection{
if ($this->transOff) return true;
if (!$ok) return $this->RollbackTrans();
if ($this->transCnt) $this->transCnt -= 1;
- $this->_autocommit = true;
- if( ($ret = odbtp_commit($this->_connectionID)) )
+ $this->autoCommit = true;
+ if( ($ret = @odbtp_commit($this->_connectionID)) )
$ret = @odbtp_set_attr(ODB_ATTR_TRANSACTIONS, ODB_TXN_NONE, $this->_connectionID);//set transaction off
return $ret;
}
@@ -374,8 +411,8 @@ class ADODB_odbtp extends ADOConnection{
{
if ($this->transOff) return true;
if ($this->transCnt) $this->transCnt -= 1;
- $this->_autocommit = true;
- if( ($ret = odbtp_rollback($this->_connectionID)) )
+ $this->autoCommit = true;
+ if( ($ret = @odbtp_rollback($this->_connectionID)) )
$ret = @odbtp_set_attr(ODB_ATTR_TRANSACTIONS, ODB_TXN_NONE, $this->_connectionID);//set transaction off
return $ret;
}
@@ -392,9 +429,9 @@ class ADODB_odbtp extends ADOConnection{
function Prepare($sql)
{
if (! $this->_bindInputArray) return $sql; // no binding
- $stmt = odbtp_prepare($sql,$this->_connectionID);
+ $stmt = @odbtp_prepare($sql,$this->_connectionID);
if (!$stmt) {
- // print "Prepare Error for ($sql) ".$this->ErrorMsg()." ";
+ // print "Prepare Error for ($sql) ".$this->ErrorMsg()." ";
return $sql;
}
return array($sql,$stmt,false);
@@ -404,7 +441,7 @@ class ADODB_odbtp extends ADOConnection{
{
if (!$this->_canPrepareSP) return $sql; // Can't prepare procedures
- $stmt = odbtp_prepare_proc($sql,$this->_connectionID);
+ $stmt = @odbtp_prepare_proc($sql,$this->_connectionID);
if (!$stmt) return false;
return array($sql,$stmt);
}
@@ -441,7 +478,7 @@ class ADODB_odbtp extends ADOConnection{
else {
$name = '@'.$name;
}
- return odbtp_attach_param($stmt[1], $name, $var, $type, $maxLen);
+ return @odbtp_attach_param($stmt[1], $name, $var, $type, $maxLen);
}
/*
@@ -457,13 +494,13 @@ class ADODB_odbtp extends ADOConnection{
function UpdateBlob($table,$column,$val,$where,$blobtype='image')
{
$sql = "UPDATE $table SET $column = ? WHERE $where";
- if( !($stmt = odbtp_prepare($sql, $this->_connectionID)) )
+ if( !($stmt = @odbtp_prepare($sql, $this->_connectionID)) )
return false;
- if( !odbtp_input( $stmt, 1, ODB_BINARY, 1000000, $blobtype ) )
+ if( !@odbtp_input( $stmt, 1, ODB_BINARY, 1000000, $blobtype ) )
return false;
- if( !odbtp_set( $stmt, 1, $val ) )
+ if( !@odbtp_set( $stmt, 1, $val ) )
return false;
- return odbtp_execute( $stmt ) != false;
+ return @odbtp_execute( $stmt ) != false;
}
function IfNull( $field, $ifNull )
@@ -483,23 +520,23 @@ class ADODB_odbtp extends ADOConnection{
if (is_array($sql)) {
$stmtid = $sql[1];
} else {
- $stmtid = odbtp_prepare($sql,$this->_connectionID);
+ $stmtid = @odbtp_prepare($sql,$this->_connectionID);
if ($stmtid == false) {
$this->_errorMsg = $php_errormsg;
return false;
}
}
- $num_params = odbtp_num_params( $stmtid );
+ $num_params = @odbtp_num_params( $stmtid );
for( $param = 1; $param <= $num_params; $param++ ) {
@odbtp_input( $stmtid, $param );
@odbtp_set( $stmtid, $param, $inputarr[$param-1] );
}
- if (! odbtp_execute($stmtid) ) {
+ if (!@odbtp_execute($stmtid) ) {
return false;
}
} else if (is_array($sql)) {
$stmtid = $sql[1];
- if (!odbtp_execute($stmtid)) {
+ if (!@odbtp_execute($stmtid)) {
return false;
}
} else {
@@ -540,6 +577,19 @@ class ADORecordSet_odbtp extends ADORecordSet {
$this->_numOfFields = @odbtp_num_fields($this->_queryID);
if (!($this->_numOfRows = @odbtp_num_rows($this->_queryID)))
$this->_numOfRows = -1;
+
+ if (!$this->connection->_useUnicodeSQL) return;
+
+ if ($this->connection->odbc_driver == ODB_DRIVER_JET) {
+ if (!@odbtp_get_attr(ODB_ATTR_MAPCHARTOWCHAR,
+ $this->connection->_connectionID))
+ {
+ for ($f = 0; $f < $this->_numOfFields; $f++) {
+ if (@odbtp_field_bindtype($this->_queryID, $f) == ODB_CHAR)
+ @odbtp_bind_field($this->_queryID, $f, ODB_WCHAR);
+ }
+ }
+ }
}
function &FetchField($fieldOffset = 0)
@@ -570,7 +620,7 @@ class ADORecordSet_odbtp extends ADORecordSet {
$this->bind[strtoupper($name)] = $i;
}
}
- return $this->fields[$this->bind[strtoupper($colname)]];
+ return $this->fields[$this->bind[strtoupper($colname)]];
}
function _fetch_odbtp($type=0)
@@ -597,18 +647,18 @@ class ADORecordSet_odbtp extends ADORecordSet {
{
if (!$this->_fetch_odbtp(ODB_FETCH_FIRST)) return false;
$this->EOF = false;
- $this->_currentRow = 0;
- return true;
+ $this->_currentRow = 0;
+ return true;
}
- function MoveLast()
- {
+ function MoveLast()
+ {
if (!$this->_fetch_odbtp(ODB_FETCH_LAST)) return false;
$this->EOF = false;
$this->_currentRow = $this->_numOfRows - 1;
- return true;
- }
-
+ return true;
+ }
+
function NextRecordSet()
{
if (!@odbtp_next_result($this->_queryID)) return false;
@@ -625,4 +675,53 @@ class ADORecordSet_odbtp extends ADORecordSet {
}
}
-?>
\ No newline at end of file
+class ADORecordSet_odbtp_mssql extends ADORecordSet_odbtp {
+
+ var $databaseType = 'odbtp_mssql';
+
+ function ADORecordSet_odbtp_mssql($id,$mode=false)
+ {
+ return $this->ADORecordSet_odbtp($id,$mode);
+ }
+}
+
+class ADORecordSet_odbtp_access extends ADORecordSet_odbtp {
+
+ var $databaseType = 'odbtp_access';
+
+ function ADORecordSet_odbtp_access($id,$mode=false)
+ {
+ return $this->ADORecordSet_odbtp($id,$mode);
+ }
+}
+
+class ADORecordSet_odbtp_vfp extends ADORecordSet_odbtp {
+
+ var $databaseType = 'odbtp_vfp';
+
+ function ADORecordSet_odbtp_vfp($id,$mode=false)
+ {
+ return $this->ADORecordSet_odbtp($id,$mode);
+ }
+}
+
+class ADORecordSet_odbtp_oci8 extends ADORecordSet_odbtp {
+
+ var $databaseType = 'odbtp_oci8';
+
+ function ADORecordSet_odbtp_oci8($id,$mode=false)
+ {
+ return $this->ADORecordSet_odbtp($id,$mode);
+ }
+}
+
+class ADORecordSet_odbtp_sybase extends ADORecordSet_odbtp {
+
+ var $databaseType = 'odbtp_sybase';
+
+ function ADORecordSet_odbtp_sybase($id,$mode=false)
+ {
+ return $this->ADORecordSet_odbtp($id,$mode);
+ }
+}
+?>
diff --git a/lib/adodb/drivers/adodb-odbtp_unicode.inc.php b/lib/adodb/drivers/adodb-odbtp_unicode.inc.php
index 78ac4d75f17..7d12705114f 100644
--- a/lib/adodb/drivers/adodb-odbtp_unicode.inc.php
+++ b/lib/adodb/drivers/adodb-odbtp_unicode.inc.php
@@ -1,6 +1,6 @@
ADODB_odbtp();
}
}
-
-class ADORecordSet_odbtp_unicode extends ADORecordSet_odbtp {
- var $databaseType = 'odbtp_unicode';
-
- function ADORecordSet_odbtp_unicode($queryID,$mode=false)
- {
- $this->ADORecordSet_odbtp($queryID, $mode);
- }
-
- function _initrs()
- {
- $this->_numOfFields = @odbtp_num_fields($this->_queryID);
- if (!($this->_numOfRows = @odbtp_num_rows($this->_queryID)))
- $this->_numOfRows = -1;
-
- if ($this->connection->odbc_driver == ODB_DRIVER_JET) {
- for ($f = 0; $f < $this->_numOfFields; $f++) {
- if (odbtp_field_bindtype($this->_queryID, $f) == ODB_CHAR)
- odbtp_bind_field($this->_queryID, $f, ODB_WCHAR);
- }
- }
- }
-}
-?>
\ No newline at end of file
+?>
diff --git a/lib/adodb/drivers/adodb-oracle.inc.php b/lib/adodb/drivers/adodb-oracle.inc.php
index 3242805ad46..45c71164c6d 100644
--- a/lib/adodb/drivers/adodb-oracle.inc.php
+++ b/lib/adodb/drivers/adodb-oracle.inc.php
@@ -1,6 +1,6 @@
fetchMode = $mode;
diff --git a/lib/adodb/drivers/adodb-postgres.inc.php b/lib/adodb/drivers/adodb-postgres.inc.php
index c766c0db23e..22d33a4ba37 100644
--- a/lib/adodb/drivers/adodb-postgres.inc.php
+++ b/lib/adodb/drivers/adodb-postgres.inc.php
@@ -1,6 +1,6 @@
0 AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum";
+ // used when schema defined
var $metaColumnsSQL1 = "SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, a.attnum
FROM pg_class c, pg_attribute a, pg_type t, pg_namespace n
-WHERE relkind = 'r' AND (c.relname='%s' or c.relname = lower('%s'))
+WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s'))
and c.relnamespace=n.oid and n.nspname='%s'
and a.attname not like '....%%' AND a.attnum > 0
AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum";
@@ -101,7 +102,7 @@ WHERE relkind = 'r' AND (c.relname='%s' or c.relname = lower('%s'))
var $_dropSeqSQL = "DROP SEQUENCE %s";
var $metaDefaultsSQL = "SELECT d.adnum as num, d.adsrc as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname='%s' order by d.adnum";
var $random = 'random()'; /// random function
- var $autoRollback = true; // apparently pgsql does not autorollback properly before 4.3.4
+ var $autoRollback = true; // apparently pgsql does not autorollback properly before php 4.3.4
// http://bugs.php.net/bug.php?id=25404
var $_bindInputArray = false; // requires postgresql 7.3+ and ability to modify database
@@ -128,12 +129,12 @@ WHERE relkind = 'r' AND (c.relname='%s' or c.relname = lower('%s'))
$this->version = $arr;
return $arr;
}
-/*
+
function IfNull( $field, $ifNull )
{
- return " NULLIF($field, $ifNull) "; // if PGSQL
+ return " coalesce($field, $ifNull) ";
}
-*/
+
// get the last id - never tested
function pg_insert_id($tablename,$fieldname)
{
@@ -150,10 +151,12 @@ WHERE relkind = 'r' AND (c.relname='%s' or c.relname = lower('%s'))
Using a OID as a unique identifier is not generally wise.
Unless you are very careful, you might end up with a tuple having
a different OID if a database must be reloaded. */
- function _insertid()
+ function _insertid($table,$column)
{
if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false;
- return pg_getlastoid($this->_resultid);
+ $oid = pg_getlastoid($this->_resultid);
+ // to really return the id, we need the table and column-name, else we can only return the oid != id
+ return empty($table) || empty($column) ? $oid : $this->GetOne("SELECT $column FROM $table WHERE oid=".(int)$oid);
}
// I get this error with PHP before 4.0.6 - jlim
@@ -198,12 +201,26 @@ a different OID if a database must be reloaded. */
}
function &MetaTables($ttype=false,$showSchema=false,$mask=false)
- {
+ {
+ $info = $this->ServerInfo();
+ if ($info['version'] >= 7.3) {
+ $this->metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%'
+ and schemaname not in ( 'pg_catalog','information_schema')
+ union
+ select viewname,'V' from pg_views where viewname not like 'pg\_%' and schemaname not in ( 'pg_catalog','information_schema') ";
+ }
if ($mask) {
$save = $this->metaTablesSQL;
$mask = $this->qstr(strtolower($mask));
- $this->metaTablesSQL = "
-select tablename,'T' from pg_tables where tablename like $mask union
+ if ($info['version']>=7.3)
+ $this->metaTablesSQL = "
+select tablename,'T' from pg_tables where tablename like $mask and schemaname not in ( 'pg_catalog','information_schema')
+ union
+select viewname,'V' from pg_views where viewname like $mask and schemaname not in ( 'pg_catalog','information_schema') ";
+ else
+ $this->metaTablesSQL = "
+select tablename,'T' from pg_tables where tablename like $mask
+ union
select viewname,'V' from pg_views where viewname like $mask";
}
$ret =& ADOConnection::MetaTables($ttype,$showSchema);
@@ -331,6 +348,15 @@ select viewname,'V' from pg_views where viewname like $mask";
return $rez;
}
+ /*
+ Hueristic - not guaranteed to work.
+ */
+ function GuessOID($oid)
+ {
+ if (strlen($oid)>16) return false;
+ return is_numeric($oid);
+ }
+
/*
* If an OID is detected, then we use pg_lo_* to open the oid file and read the
* real blob from the db using the oid supplied as a parameter. If you are storing
@@ -339,20 +365,24 @@ select viewname,'V' from pg_views where viewname like $mask";
* contributed by Mattia Rossi mattia@technologist.com
*
* see http://www.postgresql.org/idocs/index.php?largeobjects.html
+ *
+ * Since adodb 4.54, this returns the blob, instead of sending it to stdout. Also
+ * added maxsize parameter, which defaults to $db->maxblobsize if not defined.
*/
- function BlobDecode( $blob)
- {
- if (strlen($blob) > 24) return $blob;
+ function BlobDecode($blob,$maxsize=false,$hastrans=true)
+ {
+ if (!$this->GuessOID($blob)) return $blob;
- @pg_exec($this->_connectionID,"begin");
+ if ($hastrans) @pg_exec($this->_connectionID,"begin");
$fd = @pg_lo_open($this->_connectionID,$blob,"r");
if ($fd === false) {
- @pg_exec($this->_connectionID,"commit");
+ if ($hastrans) @pg_exec($this->_connectionID,"commit");
return $blob;
}
- $realblob = @pg_loreadall($fd);
+ if (!$maxsize) $maxsize = $this->maxblobsize;
+ $realblob = @pg_loread($fd,$maxsize);
@pg_loclose($fd);
- @pg_exec($this->_connectionID,"commit");
+ if ($hastrans) @pg_exec($this->_connectionID,"commit");
return $realblob;
}
@@ -408,8 +438,10 @@ select viewname,'V' from pg_views where viewname like $mask";
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
- if ($rs === false) return false;
-
+ if ($rs === false) {
+ $false = false;
+ return $false;
+ }
if (!empty($this->metaKeySQL)) {
// If we want the primary keys, we have to issue a separate query
// Of course, a modified version of the metaColumnsSQL query using a
@@ -462,7 +494,10 @@ select viewname,'V' from pg_views where viewname like $mask";
$fld->max_length = $rs->fields[2];
if ($fld->max_length <= 0) $fld->max_length = $rs->fields[3]-4;
if ($fld->max_length <= 0) $fld->max_length = -1;
-
+ if ($fld->type == 'numeric') {
+ $fld->scale = $fld->max_length & 0xFFFF;
+ $fld->max_length >>= 16;
+ }
// dannym
// 5 hasdefault; 6 num-of-column
$fld->has_default = ($rs->fields[5] == 't');
@@ -491,7 +526,7 @@ select viewname,'V' from pg_views where viewname like $mask";
$rs->MoveNext();
}
$rs->Close();
- return $retarr;
+ return empty($retarr) ? false : $retarr;
}
@@ -536,7 +571,8 @@ WHERE c2.relname=\'%s\' or c2.relname=lower(\'%s\')';
$ADODB_FETCH_MODE = $save;
if (!is_object($rs)) {
- return FALSE;
+ $false = false;
+ return $false;
}
$col_names = $this->MetaColumnNames($table,true);
@@ -779,10 +815,12 @@ class ADORecordSet_postgres64 extends ADORecordSet{
{
case ADODB_FETCH_NUM: $this->fetchMode = PGSQL_NUM; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = PGSQL_ASSOC; break;
- default:
+
case ADODB_FETCH_DEFAULT:
- case ADODB_FETCH_BOTH:$this->fetchMode = PGSQL_BOTH; break;
+ case ADODB_FETCH_BOTH:
+ default: $this->fetchMode = PGSQL_BOTH; break;
}
+ $this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID);
}
@@ -911,6 +949,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{
case 'NAME':
case 'BPCHAR':
case '_VARCHAR':
+ case 'INET':
if ($len <= $this->blobSize) return 'C';
case 'TEXT':
diff --git a/lib/adodb/drivers/adodb-postgres7.inc.php b/lib/adodb/drivers/adodb-postgres7.inc.php
index 07d0f0887af..812bbd4241e 100644
--- a/lib/adodb/drivers/adodb-postgres7.inc.php
+++ b/lib/adodb/drivers/adodb-postgres7.inc.php
@@ -1,6 +1,6 @@
ADODB_postgres64();
+ if (ADODB_ASSOC_CASE !== 2) {
+ $this->rsPrefix .= 'assoc_';
+ }
}
@@ -87,41 +90,6 @@ function MetaForeignKeys($table, $owner=false, $upper=false)
}
-
- function xMetaForeignKeys($table, $owner=false, $upper=false)
- {
-
- $sql = '
-SELECT t.tgargs as args
- FROM pg_trigger t,
- pg_class c,
- pg_class c2,
- pg_proc f
- WHERE t.tgenabled
- AND t.tgrelid=c.oid
- AND t.tgconstrrelid=c2.oid
- AND t.tgfoid=f.oid
- AND f.proname ~ \'^RI_FKey_check_ins\'
- AND t.tgargs like \'$1\\\000'.strtolower($table).'%\'
- ORDER BY t.tgrelid';
-
- $rs = $this->Execute($sql);
- if ($rs && !$rs->EOF) {
- $arr =& $rs->GetArray();
- $a = array();
- foreach($arr as $v) {
- $data = explode(chr(0), $v['args']);
- if ($upper) {
- $a[] = array(strtoupper($data[2]) => strtoupper($data[4].'='.$data[5]));
- } else {
- $a[] = array($data[2] => $data[4].'='.$data[5]);
- }
-
- }
- return $a;
- }
- else return false;
- }
// this is a set of functions for managing client encoding - very important if the encodings
// of your database and your output target (i.e. HTML) don't match
@@ -189,4 +157,74 @@ class ADORecordSet_postgres7 extends ADORecordSet_postgres64{
}
}
+
+class ADORecordSet_assoc_postgres7 extends ADORecordSet_postgres64{
+
+ var $databaseType = "postgres7";
+
+
+ function ADORecordSet_assoc_postgres7($queryID,$mode=false)
+ {
+ $this->ADORecordSet_postgres64($queryID,$mode);
+ }
+
+ function _fetch()
+ {
+ if ($this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0)
+ return false;
+
+ $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
+
+ if ($this->fields) {
+ if (isset($this->_blobArr)) $this->_fixblobs();
+ $this->_updatefields();
+ }
+
+ return (is_array($this->fields));
+ }
+
+ // Create associative array
+ function _updatefields()
+ {
+ if (ADODB_ASSOC_CASE == 2) return; // native
+
+ $arr = array();
+ $lowercase = (ADODB_ASSOC_CASE == 0);
+
+ foreach($this->fields as $k => $v) {
+ if (is_integer($k)) $arr[$k] = $v;
+ else {
+ if ($lowercase)
+ $arr[strtolower($k)] = $v;
+ else
+ $arr[strtoupper($k)] = $v;
+ }
+ }
+ $this->fields = $arr;
+ }
+
+ function MoveNext()
+ {
+ if (!$this->EOF) {
+ $this->_currentRow++;
+ if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) {
+ $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
+
+ if (is_array($this->fields)) {
+ if ($this->fields) {
+ if (isset($this->_blobArr)) $this->_fixblobs();
+
+ $this->_updatefields();
+ }
+ return true;
+ }
+ }
+
+
+ $this->fields = false;
+ $this->EOF = true;
+ }
+ return false;
+ }
+}
?>
\ No newline at end of file
diff --git a/lib/adodb/drivers/adodb-proxy.inc.php b/lib/adodb/drivers/adodb-proxy.inc.php
index 4e5a9dd355f..41518a3c052 100644
--- a/lib/adodb/drivers/adodb-proxy.inc.php
+++ b/lib/adodb/drivers/adodb-proxy.inc.php
@@ -1,6 +1,6 @@
ADODB_odbc();
}
+ function ServerInfo()
+ {
+ $info = ADODB_odbc::ServerInfo();
+ if (!$info['version'] && preg_match('/([0-9.]+)/',$info['description'],$matches)) {
+ $info['version'] = $matches[1];
+ }
+ return $info;
+ }
+
+ function MetaPrimaryKeys($table)
+ {
+ $table = $this->Quote(strtoupper($table));
+
+ return $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table AND mode='KEY' ORDER BY pos");
+ }
+
+ function &MetaIndexes ($table, $primary = FALSE)
+ {
+ $table = $this->Quote(strtoupper($table));
+
+ $sql = "SELECT INDEXNAME,TYPE,COLUMNNAME FROM INDEXCOLUMNS ".
+ " WHERE TABLENAME=$table".
+ " ORDER BY INDEXNAME,COLUMNNO";
+
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
+
+ $rs = $this->Execute($sql);
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ }
+ $ADODB_FETCH_MODE = $save;
+
+ if (!is_object($rs)) {
+ return FALSE;
+ }
+
+ $indexes = array();
+ while ($row = $rs->FetchRow()) {
+ $indexes[$row[0]]['unique'] = $row[1] == 'UNIQUE';
+ $indexes[$row[0]]['columns'][] = $row[2];
+ }
+ if ($primary) {
+ $indexes['SYSPRIMARYKEYINDEX'] = array(
+ 'unique' => True, // by definition
+ 'columns' => $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table AND mode='KEY' ORDER BY pos"),
+ );
+ }
+ return $indexes;
+ }
+
+ function &MetaColumns ($table)
+ {
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
+ $table = $this->Quote(strtoupper($table));
+
+ $retarr = array();
+ foreach($this->GetAll("SELECT COLUMNNAME,DATATYPE,LEN,DEC,NULLABLE,MODE,\"DEFAULT\",CASE WHEN \"DEFAULT\" IS NULL THEN 0 ELSE 1 END AS HAS_DEFAULT FROM COLUMNS WHERE tablename=$table ORDER BY pos") as $column)
+ {
+ $fld = new ADOFieldObject();
+ $fld->name = $column[0];
+ $fld->type = $column[1];
+ $fld->max_length = $fld->type == 'LONG' ? 2147483647 : $column[2];
+ $fld->scale = $column[3];
+ $fld->not_null = $column[4] == 'NO';
+ $fld->primary_key = $column[5] == 'KEY';
+ if ($fld->has_default = $column[7]) {
+ if ($fld->primary_key && $column[6] == 'DEFAULT SERIAL (1)') {
+ $fld->auto_increment = true;
+ $fld->has_default = false;
+ } else {
+ $fld->default_value = $column[6];
+ switch($fld->type) {
+ case 'VARCHAR':
+ case 'CHARACTER':
+ case 'LONG':
+ $fld->default_value = $column[6];
+ break;
+ default:
+ $fld->default_value = trim($column[6]);
+ break;
+ }
+ }
+ }
+ $retarr[$fld->name] = $fld;
+ }
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ }
+ $ADODB_FETCH_MODE = $save;
+
+ return $retarr;
+ }
+
+ function MetaColumnNames($table)
+ {
+ $table = $this->Quote(strtoupper($table));
+
+ return $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table ORDER BY pos");
+ }
+
+ // unlike it seems, this depends on the db-session and works in a multiuser environment
+ function _insertid($table,$column)
+ {
+ return empty($table) ? False : $this->GetOne("SELECT $table.CURRVAL FROM DUAL");
+ }
+
/*
SelectLimit implementation problems:
diff --git a/lib/adodb/drivers/adodb-sqlanywhere.inc.php b/lib/adodb/drivers/adodb-sqlanywhere.inc.php
index e6a24e0829a..d7775f9de6e 100644
--- a/lib/adodb/drivers/adodb-sqlanywhere.inc.php
+++ b/lib/adodb/drivers/adodb-sqlanywhere.inc.php
@@ -1,6 +1,6 @@
Execute("select * from $tab limit 1");
- if (!$rs) return false;
+ if (!$rs) {
+ $false = false;
+ return $false;
+ }
$arr = array();
for ($i=0,$max=$rs->_numOfFields; $i < $max; $i++) {
$fld =& $rs->FetchField($i);
@@ -187,7 +190,7 @@ class ADODB_sqlite extends ADOConnection {
$MAXLOOPS = 100;
//$this->debug=1;
while (--$MAXLOOPS>=0) {
- $num = $this->GetOne("select id from $seq");
+ @($num = $this->GetOne("select id from $seq"));
if ($num === false) {
$this->Execute(sprintf($this->_genSeqSQL ,$seq));
$start -= 1;
@@ -231,6 +234,51 @@ class ADODB_sqlite extends ADOConnection {
return @sqlite_close($this->_connectionID);
}
+ function &MetaIndexes ($table, $primary = FALSE, $owner=false)
+ {
+ $false = false;
+ // save old fetch mode
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
+ $SQL=sprintf("SELECT name,sql FROM sqlite_master WHERE type='index' AND tbl_name='%s'", strtolower($table));
+ $rs = $this->Execute($SQL);
+ if (!is_object($rs)) {
+ if (isset($savem))
+ $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ return $false;
+ }
+
+ $indexes = array ();
+ while ($row = $rs->FetchRow()) {
+ if ($primary && preg_match("/primary/i",$row[1]) == 0) continue;
+ if (!isset($indexes[$row[0]])) {
+
+ $indexes[$row[0]] = array(
+ 'unique' => preg_match("/unique/i",$row[1]),
+ 'columns' => array());
+ }
+ /**
+ * There must be a more elegant way of doing this,
+ * the index elements appear in the SQL statement
+ * in cols[1] between parentheses
+ * e.g CREATE UNIQUE INDEX ware_0 ON warehouse (org,warehouse)
+ */
+ $cols = explode("(",$row[1]);
+ $cols = explode(")",$cols[1]);
+ array_pop($cols);
+ $indexes[$row[0]]['columns'] = $cols;
+ }
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ }
+ return $indexes;
+ }
}
@@ -255,6 +303,7 @@ class ADORecordset_sqlite extends ADORecordSet {
case ADODB_FETCH_ASSOC: $this->fetchMode = SQLITE_ASSOC; break;
default: $this->fetchMode = SQLITE_BOTH; break;
}
+ $this->adodbFetchMode = $mode;
$this->_queryID = $queryID;
diff --git a/lib/adodb/drivers/adodb-sqlitepo.inc.php b/lib/adodb/drivers/adodb-sqlitepo.inc.php
index 3aca139a3a7..a3908fdf320 100644
--- a/lib/adodb/drivers/adodb-sqlitepo.inc.php
+++ b/lib/adodb/drivers/adodb-sqlitepo.inc.php
@@ -1,6 +1,6 @@
databaseName = $dbName;
if ($this->_connectionID) {
return @sybase_select_db($dbName);
@@ -105,10 +106,14 @@ class ADODB_sybase extends ADOConnection {
/* Returns: the last error message from previous database operation
Note: This function is NOT available for Microsoft SQL Server. */
- function ErrorMsg()
+
+ function ErrorMsg()
{
if ($this->_logsql) return $this->_errorMsg;
- $this->_errorMsg = sybase_get_last_message();
+ if (function_exists('sybase_get_last_message'))
+ $this->_errorMsg = sybase_get_last_message();
+ else
+ $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : 'SYBASE error messages not supported on this platform';
return $this->_errorMsg;
}
@@ -151,12 +156,12 @@ class ADODB_sybase extends ADOConnection {
$rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
return $rs;
}
- $cnt = ($nrows > 0) ? $nrows : 0;
+ $cnt = ($nrows >= 0) ? $nrows : 999999999;
if ($offset > 0 && $cnt) $cnt += $offset;
$this->Execute("set rowcount $cnt");
$rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,0);
- $this->Execute("set rowcount 0");
+ $this->Execute("set rowcount 0");
return $rs;
}
diff --git a/lib/adodb/drivers/adodb-vfp.inc.php b/lib/adodb/drivers/adodb-vfp.inc.php
index 44538c21083..6a33b89997e 100644
--- a/lib/adodb/drivers/adodb-vfp.inc.php
+++ b/lib/adodb/drivers/adodb-vfp.inc.php
@@ -1,6 +1,6 @@
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'ar',
+ DB_ERROR => 'ÎØÃ ÛíÑ ãÍÏÏ',
+ DB_ERROR_ALREADY_EXISTS => 'ãæÌæÏ ãÓÈÞÇ',
+ DB_ERROR_CANNOT_CREATE => 'áÇ íãßä ÅäÔÇÁ',
+ DB_ERROR_CANNOT_DELETE => 'áÇ íãßä ÍÐÝ',
+ DB_ERROR_CANNOT_DROP => 'áÇ íãßä ÍÐÝ',
+ DB_ERROR_CONSTRAINT => 'ÚãáíÉ ÅÏÎÇá ããäæÚÉ',
+ DB_ERROR_DIVZERO => 'ÚãáíÉ ÇáÊÞÓíã Úáì ÕÝÑ',
+ DB_ERROR_INVALID => 'ÛíÑ ÕÍíÍ',
+ DB_ERROR_INVALID_DATE => 'ÕíÛÉ æÞÊ Ãæ ÊÇÑíÎ ÛíÑ ÕÍíÍÉ',
+ DB_ERROR_INVALID_NUMBER => 'ÕíÛÉ ÑÞã ÛíÑ ÕÍíÍÉ',
+ DB_ERROR_MISMATCH => 'ÛíÑ ãÊØÇÈÞ',
+ DB_ERROR_NODBSELECTED => 'áã íÊã ÅÎÊíÇÑ ÞÇÚÏÉ ÇáÈíÇäÇÊ ÈÚÏ',
+ DB_ERROR_NOSUCHFIELD => 'áíÓ åäÇáß ÍÞá ÈåÐÇ ÇáÇÓã',
+ DB_ERROR_NOSUCHTABLE => 'áíÓ åäÇáß ÌÏæá ÈåÐÇ ÇáÇÓã',
+ DB_ERROR_NOT_CAPABLE => 'ÞÇÚÏÉ ÇáÈíÇäÇÊ ÇáãÑÊÈØ ÈåÇ ÛíÑ ÞÇÏÑÉ',
+ DB_ERROR_NOT_FOUND => 'áã íÊã ÅíÌÇÏå',
+ DB_ERROR_NOT_LOCKED => 'ÛíÑ ãÞÝæá',
+ DB_ERROR_SYNTAX => 'ÎØÃ Ýí ÇáÕíÛÉ',
+ DB_ERROR_UNSUPPORTED => 'ÛíÑ ãÏÚæã',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'ÚÏÏ ÇáÞíã Ýí ÇáÓÌá',
+ DB_ERROR_INVALID_DSN => 'DNS ÛíÑ ÕÍíÍ',
+ DB_ERROR_CONNECT_FAILED => 'ÝÔá ÚãáíÉ ÇáÅÊÕÇá',
+ 0 => 'áíÓ åäÇáß ÃÎØÇÁ', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'ÇáÈíÇäÇÊ ÇáãÒæÏÉ ÛíÑ ßÇÝíÉ',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'áã íÊã ÅíÌÇÏ ÇáÅÖÇÝÉ ÇáãÊÚáÞÉ',
+ DB_ERROR_NOSUCHDB => 'áíÓ åäÇáß ÞÇÚÏÉ ÈíÇäÇÊ ÈåÐÇ ÇáÇÓã',
+ DB_ERROR_ACCESS_VIOLATION => 'ÓãÇÍíÇÊ ÛíÑ ßÇÝíÉ'
+);
+?>
+
diff --git a/lib/adodb/lang/adodb-da.inc.php b/lib/adodb/lang/adodb-da.inc.php
new file mode 100644
index 00000000000..b0394a8d4ef
--- /dev/null
+++ b/lib/adodb/lang/adodb-da.inc.php
@@ -0,0 +1,33 @@
+ 'da',
+ DB_ERROR => 'ukendt fejl',
+ DB_ERROR_ALREADY_EXISTS => 'eksisterer allerede',
+ DB_ERROR_CANNOT_CREATE => 'kan ikke oprette',
+ DB_ERROR_CANNOT_DELETE => 'kan ikke slette',
+ DB_ERROR_CANNOT_DROP => 'kan ikke droppe',
+ DB_ERROR_CONSTRAINT => 'begrænsning krænket',
+ DB_ERROR_DIVZERO => 'division med nul',
+ DB_ERROR_INVALID => 'ugyldig',
+ DB_ERROR_INVALID_DATE => 'ugyldig dato eller klokkeslet',
+ DB_ERROR_INVALID_NUMBER => 'ugyldigt tal',
+ DB_ERROR_MISMATCH => 'mismatch',
+ DB_ERROR_NODBSELECTED => 'ingen database valgt',
+ DB_ERROR_NOSUCHFIELD => 'felt findes ikke',
+ DB_ERROR_NOSUCHTABLE => 'tabel findes ikke',
+ DB_ERROR_NOT_CAPABLE => 'DB backend opgav',
+ DB_ERROR_NOT_FOUND => 'ikke fundet',
+ DB_ERROR_NOT_LOCKED => 'ikke låst',
+ DB_ERROR_SYNTAX => 'syntaksfejl',
+ DB_ERROR_UNSUPPORTED => 'ikke understøttet',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'resulterende antal felter svarer ikke til forespørgslens antal felter',
+ DB_ERROR_INVALID_DSN => 'ugyldig DSN',
+ DB_ERROR_CONNECT_FAILED => 'tilslutning mislykkedes',
+ 0 => 'ingen fejl', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'utilstrækkelige data angivet',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'udvidelse ikke fundet',
+ DB_ERROR_NOSUCHDB => 'database ikke fundet',
+ DB_ERROR_ACCESS_VIOLATION => 'utilstrækkelige rettigheder'
+);
+?>
\ No newline at end of file
diff --git a/lib/adodb/lang/adodb-esperanto.inc.php b/lib/adodb/lang/adodb-esperanto.inc.php
new file mode 100644
index 00000000000..60ae42f982f
--- /dev/null
+++ b/lib/adodb/lang/adodb-esperanto.inc.php
@@ -0,0 +1,35 @@
+ 'eo',
+ DB_ERROR => 'nekonata eraro',
+ DB_ERROR_ALREADY_EXISTS => 'jam ekzistas',
+ DB_ERROR_CANNOT_CREATE => 'maleblas krei',
+ DB_ERROR_CANNOT_DELETE => 'maleblas elimini',
+ DB_ERROR_CANNOT_DROP => 'maleblas elimini (drop)',
+ DB_ERROR_CONSTRAINT => 'rompo de kondicxoj de provo',
+ DB_ERROR_DIVZERO => 'divido per 0 (nul)',
+ DB_ERROR_INVALID => 'malregule',
+ DB_ERROR_INVALID_DATE => 'malregula dato kaj tempo',
+ DB_ERROR_INVALID_NUMBER => 'malregula nombro',
+ DB_ERROR_MISMATCH => 'eraro',
+ DB_ERROR_NODBSELECTED => 'datumbazo ne elektita',
+ DB_ERROR_NOSUCHFIELD => 'ne ekzistas kampo',
+ DB_ERROR_NOSUCHTABLE => 'ne ekzistas tabelo',
+ DB_ERROR_NOT_CAPABLE => 'DBMS ne povas',
+ DB_ERROR_NOT_FOUND => 'ne trovita',
+ DB_ERROR_NOT_LOCKED => 'ne blokita',
+ DB_ERROR_SYNTAX => 'sintaksa eraro',
+ DB_ERROR_UNSUPPORTED => 'ne apogata',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'nombrilo de valoroj en linio',
+ DB_ERROR_INVALID_DSN => 'malregula DSN-o',
+ DB_ERROR_CONNECT_FAILED => 'konekto malsukcesa',
+ 0 => 'cxio bone', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'ne suficxe da datumo',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'etendo ne trovita',
+ DB_ERROR_NOSUCHDB => 'datumbazo ne ekzistas',
+ DB_ERROR_ACCESS_VIOLATION => 'ne suficxe da rajto por atingo'
+);
+?>
\ No newline at end of file
diff --git a/lib/adodb/lang/adodb-hu.inc.php b/lib/adodb/lang/adodb-hu.inc.php
new file mode 100644
index 00000000000..d5b91d9c08a
--- /dev/null
+++ b/lib/adodb/lang/adodb-hu.inc.php
@@ -0,0 +1,34 @@
+
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'hu',
+ DB_ERROR => 'ismeretlen hiba',
+ DB_ERROR_ALREADY_EXISTS => 'már létezik',
+ DB_ERROR_CANNOT_CREATE => 'nem sikerült létrehozni',
+ DB_ERROR_CANNOT_DELETE => 'nem sikerült törölni',
+ DB_ERROR_CANNOT_DROP => 'nem sikerült eldobni',
+ DB_ERROR_CONSTRAINT => 'szabályok megszegése',
+ DB_ERROR_DIVZERO => 'osztás nullával',
+ DB_ERROR_INVALID => 'érvénytelen',
+ DB_ERROR_INVALID_DATE => 'érvénytelen dátum vagy idõ',
+ DB_ERROR_INVALID_NUMBER => 'érvénytelen szám',
+ DB_ERROR_MISMATCH => 'nem megfelelõ',
+ DB_ERROR_NODBSELECTED => 'nincs kiválasztott adatbázis',
+ DB_ERROR_NOSUCHFIELD => 'nincs ilyen mezõ',
+ DB_ERROR_NOSUCHTABLE => 'nincs ilyen tábla',
+ DB_ERROR_NOT_CAPABLE => 'DB backend nem támogatja',
+ DB_ERROR_NOT_FOUND => 'nem található',
+ DB_ERROR_NOT_LOCKED => 'nincs lezárva',
+ DB_ERROR_SYNTAX => 'szintaktikai hiba',
+ DB_ERROR_UNSUPPORTED => 'nem támogatott',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'soron végzett érték számlálás',
+ DB_ERROR_INVALID_DSN => 'hibás DSN',
+ DB_ERROR_CONNECT_FAILED => 'sikertelen csatlakozás',
+ 0 => 'nincs hiba', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'túl kevés az adat',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'bõvítmény nem található',
+ DB_ERROR_NOSUCHDB => 'nincs ilyen adatbázis',
+ DB_ERROR_ACCESS_VIOLATION => 'nincs jogosultság'
+);
+?>
\ No newline at end of file
diff --git a/lib/adodb/pear/Auth/Container/ADOdb.php b/lib/adodb/pear/Auth/Container/ADOdb.php
new file mode 100644
index 00000000000..a806bb457cc
--- /dev/null
+++ b/lib/adodb/pear/Auth/Container/ADOdb.php
@@ -0,0 +1,412 @@
+
+// | Richard Tango-Lowy |
+// +----------------------------------------------------------------------+
+//
+// $Id$
+//
+
+require_once 'Auth/Container.php';
+require_once 'adodb.inc.php';
+require_once 'adodb-pear.inc.php';
+require_once 'adodb-errorpear.inc.php';
+
+/**
+ * Storage driver for fetching login data from a database using ADOdb-PHP.
+ *
+ * This storage driver can use all databases which are supported
+ * by the ADBdb DB abstraction layer to fetch login data.
+ * See http://php.weblogs.com/adodb for information on ADOdb.
+ * NOTE: The ADOdb directory MUST be in your PHP include_path!
+ *
+ * @author Richard Tango-Lowy
+ * @package Auth
+ * @version $Revision$
+ */
+class Auth_Container_ADOdb extends Auth_Container
+{
+
+ /**
+ * Additional options for the storage container
+ * @var array
+ */
+ var $options = array();
+
+ /**
+ * DB object
+ * @var object
+ */
+ var $db = null;
+ var $dsn = '';
+
+ /**
+ * User that is currently selected from the DB.
+ * @var string
+ */
+ var $activeUser = '';
+
+ // {{{ Constructor
+
+ /**
+ * Constructor of the container class
+ *
+ * Initate connection to the database via PEAR::ADOdb
+ *
+ * @param string Connection data or DB object
+ * @return object Returns an error object if something went wrong
+ */
+ function Auth_Container_ADOdb($dsn)
+ {
+ $this->_setDefaults();
+
+ if (is_array($dsn)) {
+ $this->_parseOptions($dsn);
+
+ if (empty($this->options['dsn'])) {
+ PEAR::raiseError('No connection parameters specified!');
+ }
+ } else {
+ // Extract db_type from dsn string.
+ $this->options['dsn'] = $dsn;
+ }
+ }
+
+ // }}}
+ // {{{ _connect()
+
+ /**
+ * Connect to database by using the given DSN string
+ *
+ * @access private
+ * @param string DSN string
+ * @return mixed Object on error, otherwise bool
+ */
+ function _connect($dsn)
+ {
+ if (is_string($dsn) || is_array($dsn)) {
+ if(!$this->db) {
+ $this->db = &ADONewConnection($dsn);
+ if( $err = ADODB_Pear_error() ) {
+ return PEAR::raiseError($err);
+ }
+ }
+
+ } else {
+ return PEAR::raiseError('The given dsn was not valid in file ' . __FILE__ . ' at line ' . __LINE__,
+ 41,
+ PEAR_ERROR_RETURN,
+ null,
+ null
+ );
+ }
+
+ if(!$this->db) {
+ return PEAR::raiseError(ADODB_Pear_error());
+ } else {
+ return true;
+ }
+ }
+
+ // }}}
+ // {{{ _prepare()
+
+ /**
+ * Prepare database connection
+ *
+ * This function checks if we have already opened a connection to
+ * the database. If that's not the case, a new connection is opened.
+ *
+ * @access private
+ * @return mixed True or a DB error object.
+ */
+ function _prepare()
+ {
+ if(!$this->db) {
+ $res = $this->_connect($this->options['dsn']);
+ }
+ return true;
+ }
+
+ // }}}
+ // {{{ query()
+
+ /**
+ * Prepare query to the database
+ *
+ * This function checks if we have already opened a connection to
+ * the database. If that's not the case, a new connection is opened.
+ * After that the query is passed to the database.
+ *
+ * @access public
+ * @param string Query string
+ * @return mixed a DB_result object or DB_OK on success, a DB
+ * or PEAR error on failure
+ */
+ function query($query)
+ {
+ $err = $this->_prepare();
+ if ($err !== true) {
+ return $err;
+ }
+ return $this->db->query($query);
+ }
+
+ // }}}
+ // {{{ _setDefaults()
+
+ /**
+ * Set some default options
+ *
+ * @access private
+ * @return void
+ */
+ function _setDefaults()
+ {
+ $this->options['db_type'] = 'mysql';
+ $this->options['table'] = 'auth';
+ $this->options['usernamecol'] = 'username';
+ $this->options['passwordcol'] = 'password';
+ $this->options['dsn'] = '';
+ $this->options['db_fields'] = '';
+ $this->options['cryptType'] = 'md5';
+ }
+
+ // }}}
+ // {{{ _parseOptions()
+
+ /**
+ * Parse options passed to the container class
+ *
+ * @access private
+ * @param array
+ */
+ function _parseOptions($array)
+ {
+ foreach ($array as $key => $value) {
+ if (isset($this->options[$key])) {
+ $this->options[$key] = $value;
+ }
+ }
+
+ /* Include additional fields if they exist */
+ if(!empty($this->options['db_fields'])){
+ if(is_array($this->options['db_fields'])){
+ $this->options['db_fields'] = join($this->options['db_fields'], ', ');
+ }
+ $this->options['db_fields'] = ', '.$this->options['db_fields'];
+ }
+ }
+
+ // }}}
+ // {{{ fetchData()
+
+ /**
+ * Get user information from database
+ *
+ * This function uses the given username to fetch
+ * the corresponding login data from the database
+ * table. If an account that matches the passed username
+ * and password is found, the function returns true.
+ * Otherwise it returns false.
+ *
+ * @param string Username
+ * @param string Password
+ * @return mixed Error object or boolean
+ */
+ function fetchData($username, $password)
+ {
+ // Prepare for a database query
+ $err = $this->_prepare();
+ if ($err !== true) {
+ return PEAR::raiseError($err->getMessage(), $err->getCode());
+ }
+
+ // Find if db_fields contains a *, i so assume all col are selected
+ if(strstr($this->options['db_fields'], '*')){
+ $sql_from = "*";
+ }
+ else{
+ $sql_from = $this->options['usernamecol'] . ", ".$this->options['passwordcol'].$this->options['db_fields'];
+ }
+
+ $query = "SELECT ".$sql_from.
+ " FROM ".$this->options['table'].
+ " WHERE ".$this->options['usernamecol']." = " . $this->db->Quote($username);
+
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ $rset = $this->db->Execute( $query );
+ $res = $rset->fetchRow();
+
+ if (DB::isError($res)) {
+ return PEAR::raiseError($res->getMessage(), $res->getCode());
+ }
+ if (!is_array($res)) {
+ $this->activeUser = '';
+ return false;
+ }
+ if ($this->verifyPassword(trim($password, "\r\n"),
+ trim($res[$this->options['passwordcol']], "\r\n"),
+ $this->options['cryptType'])) {
+ // Store additional field values in the session
+ foreach ($res as $key => $value) {
+ if ($key == $this->options['passwordcol'] ||
+ $key == $this->options['usernamecol']) {
+ continue;
+ }
+ // Use reference to the auth object if exists
+ // This is because the auth session variable can change so a static call to setAuthData does not make sence
+ if(is_object($this->_auth_obj)){
+ $this->_auth_obj->setAuthData($key, $value);
+ } else {
+ Auth::setAuthData($key, $value);
+ }
+ }
+
+ return true;
+ }
+
+ $this->activeUser = $res[$this->options['usernamecol']];
+ return false;
+ }
+
+ // }}}
+ // {{{ listUsers()
+
+ function listUsers()
+ {
+ $err = $this->_prepare();
+ if ($err !== true) {
+ return PEAR::raiseError($err->getMessage(), $err->getCode());
+ }
+
+ $retVal = array();
+
+ // Find if db_fileds contains a *, i so assume all col are selected
+ if(strstr($this->options['db_fields'], '*')){
+ $sql_from = "*";
+ }
+ else{
+ $sql_from = $this->options['usernamecol'] . ", ".$this->options['passwordcol'].$this->options['db_fields'];
+ }
+
+ $query = sprintf("SELECT %s FROM %s",
+ $sql_from,
+ $this->options['table']
+ );
+ $res = $this->db->getAll($query, null, DB_FETCHMODE_ASSOC);
+
+ if (DB::isError($res)) {
+ return PEAR::raiseError($res->getMessage(), $res->getCode());
+ } else {
+ foreach ($res as $user) {
+ $user['username'] = $user[$this->options['usernamecol']];
+ $retVal[] = $user;
+ }
+ }
+ return $retVal;
+ }
+
+ // }}}
+ // {{{ addUser()
+
+ /**
+ * Add user to the storage container
+ *
+ * @access public
+ * @param string Username
+ * @param string Password
+ * @param mixed Additional information that are stored in the DB
+ *
+ * @return mixed True on success, otherwise error object
+ */
+ function addUser($username, $password, $additional = "")
+ {
+ if (function_exists($this->options['cryptType'])) {
+ $cryptFunction = $this->options['cryptType'];
+ } else {
+ $cryptFunction = 'md5';
+ }
+
+ $additional_key = '';
+ $additional_value = '';
+
+ if (is_array($additional)) {
+ foreach ($additional as $key => $value) {
+ $additional_key .= ', ' . $key;
+ $additional_value .= ", '" . $value . "'";
+ }
+ }
+
+ $query = sprintf("INSERT INTO %s (%s, %s%s) VALUES ('%s', '%s'%s)",
+ $this->options['table'],
+ $this->options['usernamecol'],
+ $this->options['passwordcol'],
+ $additional_key,
+ $username,
+ $cryptFunction($password),
+ $additional_value
+ );
+
+ $res = $this->query($query);
+
+ if (DB::isError($res)) {
+ return PEAR::raiseError($res->getMessage(), $res->getCode());
+ } else {
+ return true;
+ }
+ }
+
+ // }}}
+ // {{{ removeUser()
+
+ /**
+ * Remove user from the storage container
+ *
+ * @access public
+ * @param string Username
+ *
+ * @return mixed True on success, otherwise error object
+ */
+ function removeUser($username)
+ {
+ $query = sprintf("DELETE FROM %s WHERE %s = '%s'",
+ $this->options['table'],
+ $this->options['usernamecol'],
+ $username
+ );
+
+ $res = $this->query($query);
+
+ if (DB::isError($res)) {
+ return PEAR::raiseError($res->getMessage(), $res->getCode());
+ } else {
+ return true;
+ }
+ }
+
+ // }}}
+}
+
+function showDbg( $string ) {
+ print "$string
";
+}
+function dump( $var, $str, $vardump = false ) {
+ print "$str ";
+ ( !$vardump ) ? ( print_r( $var )) : ( var_dump( $var ));
+ print " ";
+}
+?>
diff --git a/lib/adodb/pear/readme.Auth.txt b/lib/adodb/pear/readme.Auth.txt
new file mode 100644
index 00000000000..db283197614
--- /dev/null
+++ b/lib/adodb/pear/readme.Auth.txt
@@ -0,0 +1,20 @@
+From: Rich Tango-Lowy (richtl#arscognita.com)
+Date: Sat, May 29, 2004 11:20 am
+
+OK, I hacked out an ADOdb container for PEAR-Auth. The error handling's
+a bit of a mess, but all the methods work.
+
+Copy ADOdb.php to your pear/Auth/Container/ directory.
+
+Use the ADOdb container exactly as you would the DB
+container, but specify 'ADOdb' instead of 'DB':
+
+$dsn = "mysql://myuser:mypass@localhost/authdb";
+$a = new Auth("ADOdb", $dsn, "loginFunction");
+
+
+-------------------
+
+John Lim adds:
+
+See http://pear.php.net/manual/en/package.authentication.php
diff --git a/lib/adodb/perf/perf-db2.inc.php b/lib/adodb/perf/perf-db2.inc.php
index 0e65e74aa1b..f08e101bb96 100644
--- a/lib/adodb/perf/perf-db2.inc.php
+++ b/lib/adodb/perf/perf-db2.inc.php
@@ -1,6 +1,6 @@
fields[0].'::'.$rs->fields[1]) {
if ($check) {
$carr = explode('::',$check);
- $prefix = "';
+ $prefix = " ';
$suffix = ' ';
if (strlen($prefix)>2000) {
$prefix = '';
@@ -351,7 +351,7 @@ select a.size_for_estimate as cache_mb_estimate,
$rs->Close();
$carr = explode('::',$check);
- $prefix = "';
+ $prefix = " ';
$suffix = ' ';
if (strlen($prefix)>2000) {
$prefix = '';
diff --git a/lib/adodb/perf/perf-postgres.inc.php b/lib/adodb/perf/perf-postgres.inc.php
index 94785b3a968..68bba94aa44 100644
--- a/lib/adodb/perf/perf-postgres.inc.php
+++ b/lib/adodb/perf/perf-postgres.inc.php
@@ -1,7 +1,7 @@
databaseType,'access') !== false;
+ // note - vfp still doesn' work even with IIF enabled || $db->databaseType == 'vfp';
//$hidecnt = false;
@@ -47,20 +49,39 @@
$sel = "$rowfields, ";
if (is_array($colfield)) {
foreach ($colfield as $k => $v) {
- if (!$hidecnt) $sel .= "\n\t$aggfn(CASE WHEN $v THEN 1 ELSE 0 END) AS \"$k\", ";
- if ($aggfield)
- $sel .= "\n\t$aggfn(CASE WHEN $v THEN $aggfield ELSE 0 END) AS \"$sumlabel$k\", ";
+ $k = trim($k);
+ if (!$hidecnt) {
+ $sel .= $iif ?
+ "\n\t$aggfn(IIF($v,1,0)) AS \"$k\", "
+ :
+ "\n\t$aggfn(CASE WHEN $v THEN 1 ELSE 0 END) AS \"$k\", ";
+ }
+ if ($aggfield) {
+ $sel .= $iif ?
+ "\n\t$aggfn(IIF($v,$aggfield,0)) AS \"$sumlabel$k\", "
+ :
+ "\n\t$aggfn(CASE WHEN $v THEN $aggfield ELSE 0 END) AS \"$sumlabel$k\", ";
+ }
}
} else {
foreach ($colarr as $v) {
if (!is_numeric($v)) $vq = $db->qstr($v);
else $vq = $v;
+ $v = trim($v);
if (strlen($v) == 0 ) $v = 'null';
- if (!$hidecnt) $sel .= "\n\t$aggfn(CASE WHEN $colfield=$vq THEN 1 ELSE 0 END) AS \"$v\", ";
+ if (!$hidecnt) {
+ $sel .= $iif ?
+ "\n\t$aggfn(IIF($colfield=$vq,1,0)) AS \"$v\", "
+ :
+ "\n\t$aggfn(CASE WHEN $colfield=$vq THEN 1 ELSE 0 END) AS \"$v\", ";
+ }
if ($aggfield) {
if ($hidecnt) $label = $v;
else $label = "{$v}_$aggfield";
- $sel .= "\n\t$aggfn(CASE WHEN $colfield=$vq THEN $aggfield ELSE 0 END) AS \"$label\", ";
+ $sel .= $iif ?
+ "\n\t$aggfn(IIF($colfield=$vq,$aggfield,0)) AS \"$label\", "
+ :
+ "\n\t$aggfn(CASE WHEN $colfield=$vq THEN $aggfield ELSE 0 END) AS \"$label\", ";
}
}
}
@@ -123,7 +144,7 @@ GROUP BY CompanyName,QuantityPerUnit
#
# Query the main "product" table
# Set the rows to CompanyName and QuantityPerUnit
-# and the columns to the UnitsInStock for different ranges
+# and the columns to the UnitsInStock for diiferent ranges
# and define the joins to link to lookup tables
# "categories" and "suppliers"
#
diff --git a/lib/adodb/readme.txt b/lib/adodb/readme.txt
index cca9c96b165..97bdd9eab41 100644
--- a/lib/adodb/readme.txt
+++ b/lib/adodb/readme.txt
@@ -1,6 +1,6 @@
>> ADODB Library for PHP4
-(c) 2000-2002 John Lim (jlim@natsoft.com.my)
+(c) 2000-2004 John Lim (jlim@natsoft.com.my)
Released under both BSD and GNU Lesser GPL library license.
This means you can use it in proprietary products.
@@ -50,6 +50,8 @@ tute.htm is the tutorial.
>> More Info
For more information, including installation see readme.htm
+or visit
+ http://adodb.sourceforge.net/
>> Feature Requests and Bug Reports
diff --git a/lib/adodb/rsfilter.inc.php b/lib/adodb/rsfilter.inc.php
index c4b5ad04ad7..7f856cd8203 100644
--- a/lib/adodb/rsfilter.inc.php
+++ b/lib/adodb/rsfilter.inc.php
@@ -1,6 +1,6 @@
RecordCount();
for ($i=0; $i < $rows; $i++) {
- $fn($rs->_array[$i],$rs);
+ if (is_array ($fn)) {
+ $obj = $fn[0];
+ $method = $fn[1];
+ $obj->$method ($rs->_array[$i],$rs);
+ } else {
+ $fn($rs->_array[$i],$rs);
+ }
+
}
if (!$rs->EOF) {
$rs->_currentRow = 0;
diff --git a/lib/adodb/server.php b/lib/adodb/server.php
index 04ffb00088b..108e0929ee7 100644
--- a/lib/adodb/server.php
+++ b/lib/adodb/server.php
@@ -1,7 +1,7 @@
debug = true;
@@ -451,7 +471,12 @@ class ADODB_Session {
}
if ($persist) {
- $ok = $conn->PConnect($host, $user, $password, $database);
+ switch($persist) {
+ default:
+ case 'P': $ok = $conn->PConnect($host, $user, $password, $database); break;
+ case 'C': $ok = $conn->Connect($host, $user, $password, $database); break;
+ case 'N': $ok = $conn->NConnect($host, $user, $password, $database); break;
+ }
} else {
$ok = $conn->Connect($host, $user, $password, $database);
}
@@ -546,7 +571,6 @@ class ADODB_Session {
$expiry = time() + $lifetime;
- $qkey = $conn->quote($key);
$binary = $conn->dataProvider === 'mysql' ? '/*! BINARY */' : '';
// crc32 optimization since adodb 2.1
@@ -555,8 +579,8 @@ class ADODB_Session {
if ($debug) {
echo 'Session: Only updating date - crc32 not changed
';
}
- $sql = "UPDATE $table SET expiry = $expiry WHERE $binary sesskey = $qkey AND expiry >= " . time();
- $rs =& $conn->Execute($sql);
+ $sql = "UPDATE $table SET expiry = ".$conn->Param('0')." WHERE $binary sesskey = ".$conn->Param('1')." AND expiry >= ".$conn->Param('2');
+ $rs =& $conn->Execute($sql,array($expiry,$key,time()));
ADODB_Session::_dumprs($rs);
if ($rs) {
$rs->Close();
diff --git a/lib/adodb/tests/benchmark.php b/lib/adodb/tests/benchmark.php
index f9ccd329d10..05813759277 100644
--- a/lib/adodb/tests/benchmark.php
+++ b/lib/adodb/tests/benchmark.php
@@ -8,7 +8,7 @@
EOF) {
if ($cnt++ > 1000) break;
}
-echo " -------------------------------------------------------- \n\n\n";
+echo " -------------------------------------------------------- \n\n\n";
$stmt = $DB->PrepareStmt("select * from products");
$rs = $stmt->Execute();
diff --git a/lib/adodb/tests/test-datadict.php b/lib/adodb/tests/test-datadict.php
index e04e0c5a761..de0faa42f5e 100644
--- a/lib/adodb/tests/test-datadict.php
+++ b/lib/adodb/tests/test-datadict.php
@@ -1,7 +1,7 @@
$dbType";
$db = NewADOConnection($dbType);
$dict = NewDataDictionary($db);
@@ -78,19 +78,33 @@ TS T DEFTIMESTAMP";
printsqla($dbType,$sqla);
if (file_exists('d:\inetpub\wwwroot\php\phplens\adodb\adodb.inc.php'))
- if ($dbType == 'mysql') {
+ if ($dbType == 'mysqlt') {
$db->Connect('localhost', "root", "", "test");
$dict->SetSchema('');
$sqla2 = $dict->ChangeTableSQL('adoxyz',$flds);
if ($sqla2) printsqla($dbType,$sqla2);
}
- if ($dbType == 'postgres') {
- $db->Connect('localhost', "tester", "test", "test");
+ if ($dbType == 'postgres') {
+ if (@$db->Connect('localhost', "tester", "test", "test"));
$dict->SetSchema('');
$sqla2 = $dict->ChangeTableSQL('adoxyz',$flds);
if ($sqla2) printsqla($dbType,$sqla2);
}
+ if ($dbType == 'odbc_mssql') {
+ $dsn = $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=localhost;Database=northwind;";
+ if (@$db->Connect($dsn, "sa", "natsoft", "test"));
+ $dict->SetSchema('');
+ $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds);
+ if ($sqla2) printsqla($dbType,$sqla2);
+ }
+
+
+
+ adodb_pr($dict->databaseType);
+ printsqla($dbType, $dict->DropColumnSQL('table',array('`col`','col2')));
+ printsqla($dbType, $dict->ChangeTableSQL('adoxyz','LASTNAME varchar(32)'));
+
}
function printsqla($dbType,$sqla)
@@ -224,6 +238,7 @@ ALTER TABLE KUTU.testtable ALTER COLUMN weight REAL NOT NULL;
--------------------------------------------------------------------------------
*/
+
echo "
Test XML Schema ";
$ff = file('xmlschema.xml');
echo "";
diff --git a/lib/adodb/tests/test-php5.php b/lib/adodb/tests/test-php5.php
index 6592503e7a2..02ae72adc1d 100644
--- a/lib/adodb/tests/test-php5.php
+++ b/lib/adodb/tests/test-php5.php
@@ -1,6 +1,6 @@
PHP ".PHP_VERSION."\n";
try {
-$dbt = 'oci8po';
+$dbt = 'mysql';
+try {
switch($dbt) {
case 'oci8po':
$db = NewADOConnection("oci8po");
+
$db->Connect('','scott','natsoft');
break;
default:
case 'mysql':
$db = NewADOConnection("mysql");
- $db->Connect('localhost','root','','test');
+ $db->Connect('localhost','roots','','northwind');
break;
case 'mysqli':
- $db = NewADOConnection("mysqli://root:@localhost/test");
+ $db = NewADOConnection("mysqli://root:@localhost/northwind");
//$db->Connect('localhost','root','','test');
break;
}
+} catch (exception $e){
+ echo "Connect Failed";
+ adodb_pr($e);
+ die();
+}
$db->debug=1;
@@ -44,16 +51,19 @@ $stmt = $db->Prepare("select * from adoxyz where ?ErrorMsg(),"\n";
$rs = $db->Execute($stmt,array(10,20));
+echo " Foreach Iterator Test (rand=".rand().") ";
$i = 0;
-foreach($rs as $v) {
+foreach($rs as $v) {
$i += 1;
- echo "rec $i: "; adodb_pr($v); adodb_pr($rs->fields);
+ echo "rec $i: "; $s1 = adodb_pr($v,true); $s2 = adodb_pr($rs->fields,true);
+ if ($s1 != $s2 && !empty($v)) {adodb_pr($s1); adodb_pr($s2);}
+ else echo "passed ";
flush();
}
if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n");
-
+else echo "Count $i is correct ";
$rs = $db->Execute("select bad from badder");
diff --git a/lib/adodb/tests/test-xmlschema.php b/lib/adodb/tests/test-xmlschema.php
index 1134a30f08e..60f6b606829 100644
--- a/lib/adodb/tests/test-xmlschema.php
+++ b/lib/adodb/tests/test-xmlschema.php
@@ -3,8 +3,8 @@
// V4.50 6 July 2004
error_reporting(E_ALL);
-
-require( "../adodb-xmlschema.inc.php" );
+include_once( "../adodb.inc.php" );
+include_once( "../adodb-xmlschema.inc.php" );
// To build the schema, start by creating a normal ADOdb connection:
$db = ADONewConnection( 'mysql' );
diff --git a/lib/adodb/tests/test.php b/lib/adodb/tests/test.php
index b247751075e..8cf9761e7fc 100644
--- a/lib/adodb/tests/test.php
+++ b/lib/adodb/tests/test.php
@@ -1,6 +1,6 @@
$msg ";
+ print "$msg ";
flush();
}
@@ -43,7 +43,8 @@ global $ADODB_EXTENSION;
function do_strtolower(&$arr)
{
foreach($arr as $k => $v) {
- $arr[$k] = strtolower($v);
+ if (is_object($v)) $arr[$k] = adodb_pr($v,true);
+ else $arr[$k] = strtolower($v);
}
}
@@ -112,37 +113,39 @@ FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_to
else $ext = '';
print "ADODB Version: $ADODB_vers Host: $db->host Database: $db->database PHP: $phpv $ext ";
flush();
+
+
$arr = $db->ServerInfo();
print_r($arr);
- echo " ";
+ echo " ";
$e = error_reporting(E_ALL-E_WARNING);
flush();
$tt = $db->Time();
- if ($tt == 0) echo '$db->Time failed ';
- else echo " db->Time: ".date('d-m-Y H:i:s',$tt);
- echo ' ';
-
- echo "Date=",$db->UserDate('2002-04-07'),' ';
+ if ($tt == 0) echo '$db->Time failed ';
+ else echo " db->Time: ".date('d-m-Y H:i:s',$tt);
+ echo ' ';
+
+ echo "Date=",$db->UserDate('2002-04-07'),' ';
print "date1 (1969-02-20) = ".$db->DBDate('1969-2-20');
- print "date1 (1999-02-20) = ".$db->DBDate('1999-2-20');
- print "date1.1 1999 = ".$db->DBDate("'1999'");
- print "date2 (1970-1-2) = ".$db->DBDate(24*3600)."";
+ print "date1 (1999-02-20) = ".$db->DBDate('1999-2-20');
+ print "date1.1 1999 = ".$db->DBDate("'1999'");
+ print "date2 (1970-1-2) = ".$db->DBDate(24*3600)."
";
print "ts1 (1999-02-20 13:40:50) = ".$db->DBTimeStamp('1999-2-20 1:40:50 pm');
- print "ts1.1 (1999-02-20 13:40:00) = ".$db->DBTimeStamp('1999-2-20 13:40');
- print "ts2 (1999-02-20) = ".$db->DBTimeStamp('1999-2-20');
- print "ts3 (1970-1-2 +/- timezone) = ".$db->DBTimeStamp(24*3600);
- print " Fractional TS (1999-2-20 13:40:50.91): ".$db->DBTimeStamp($db->UnixTimeStamp('1999-2-20 13:40:50.91+1'));
+ print "ts1.1 (1999-02-20 13:40:00) = ".$db->DBTimeStamp('1999-2-20 13:40');
+ print "ts2 (1999-02-20) = ".$db->DBTimeStamp('1999-2-20');
+ print "ts3 (1970-1-2 +/- timezone) = ".$db->DBTimeStamp(24*3600);
+ print " Fractional TS (1999-2-20 13:40:50.91): ".$db->DBTimeStamp($db->UnixTimeStamp('1999-2-20 13:40:50.91+1'));
$dd = $db->UnixDate('1999-02-20');
- print " unixdate 1999-02-20 = ".date('Y-m-d',$dd)."
";
- print "ts4 =".($db->UnixTimeStamp("19700101000101")+8*3600);
- print "ts5 =".$db->DBTimeStamp($db->UnixTimeStamp("20040110092123"));
- print "ts6 =".$db->UserTimeStamp("20040110092123");
- print "ts7 =".$db->DBTimeStamp("20040110092123");
+ print " unixdate 1999-02-20 = ".date('Y-m-d',$dd)."
";
+ print "ts4 =".($db->UnixTimeStamp("19700101000101")+8*3600);
+ print "ts5 =".$db->DBTimeStamp($db->UnixTimeStamp("20040110092123"));
+ print "ts6 =".$db->UserTimeStamp("20040110092123");
+ print "ts7 =".$db->DBTimeStamp("20040110092123");
flush();
// mssql too slow in failing bad connection
if (false && $db->databaseType != 'mssql') {
- print "
Testing bad connection. Ignore following error msgs: ";
+ print "
Testing bad connection. Ignore following error msgs: ";
$db2 = ADONewConnection();
$rez = $db2->Connect("bad connection");
$err = $db2->ErrorMsg();
@@ -154,11 +157,6 @@ FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_to
//$ADODB_COUNTRECS=false;
$rs=$db->Execute('select * from adoxyz order by id');
-
- //print_r($rs);
- //OCIFetchStatement($rs->_queryID,$rez,0,-1);//,OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW);
- //print_r($rez);
- //die();
if($rs === false) $create = true;
else $rs->Close();
@@ -184,11 +182,11 @@ FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_to
print "
Test select on empty table, FetchField when EOF, and GetInsertSQL
";
$rs = &$db->Execute("select id,firstname from ADOXYZ where id=9999");
if ($rs && !$rs->EOF) print "Error: RecordSet returned by Execute(select...') on empty table should show EOF";
- if ($rs->EOF && ($o = $rs->FetchField(0))) {
+ if ($rs->EOF && (($ox = $rs->FetchField(0)) && !empty($ox->name))) {
$record['id'] = 99;
$record['firstname'] = 'John';
$sql = $db->GetInsertSQL($rs, $record);
- if ($sql != "INSERT INTO ADOXYZ ( id, firstname ) VALUES ( 99, 'John' )") Err("GetInsertSQL does not work on empty table");
+ if (strtoupper($sql) != strtoupper("INSERT INTO ADOXYZ ( id, firstname ) VALUES ( 99, 'John' )")) Err("GetInsertSQL does not work on empty table: $sql");
} else {
Err("FetchField does not work on empty recordset, meaning GetInsertSQL will fail...");
}
@@ -277,12 +275,18 @@ FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_to
print '';
}
+ $db->debug=0;
+ $rez = $db->MetaColumns("NOSUCHTABLEHERE");
+ if ($rez !== false) {
+ Err("MetaColumns error handling failed");
+ var_dump($rez);
+ }
$db->debug=1;
$a = $db->MetaColumns('ADOXYZ');
if ($a===false) print "MetaColumns not supported ";
else {
- print "Columns of ADOXYZ: ";
- foreach($a as $v) {print_r($v); echo " ";}
+ print "Columns of ADOXYZ: ";
+ foreach($a as $v) {print_r($v); echo " ";}
echo " ";
}
@@ -291,7 +295,7 @@ FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_to
$a = $db->MetaIndexes(('ADOXYZ'),true);
if ($a===false) print "MetaIndexes not supported
";
else {
- print "Indexes of ADOXYZ: ";
+ print "Indexes of ADOXYZ: ";
adodb_pr($a);
echo " ";
}
@@ -306,6 +310,15 @@ FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_to
switch ($db->databaseType) {
+ case 'vfp':
+
+ if (0) {
+ // memo test
+ $rs = $db->Execute("select data from memo");
+ rs2html($rs);
+ }
+ break;
+
case 'postgres7':
case 'postgres64':
case 'postgres':
@@ -376,7 +389,7 @@ GO
rs2html($rs);
/*
- Test out params - works in 4.2.3 and 4.3.3 but not 4.3.0:
+ Test out params - works in PHP 4.2.3 and 4.3.3 and 4.3.8 but not 4.3.0:
CREATE PROCEDURE at_date_interval
@days INTEGER,
@@ -398,7 +411,7 @@ GO
$db->OutParameter($stmt,$begin_date,'start', 20, SQLVARCHAR );
$db->OutParameter($stmt,$end_date,'end', 20, SQLVARCHAR );
$db->Execute($stmt);
- if (empty($begin_date) or empty($end_date)) {
+ if (empty($begin_date) or empty($end_date) or $begin_date == $end_date) {
Err("MSSQL SP Test for OUT Failed");
print "begin=$begin_date end=$end_date
";
} else print "(Today +10days) = (begin=$begin_date end=$end_date)
";
@@ -407,9 +420,16 @@ GO
break;
case 'oci8':
case 'oci8po':
+
+ # cleanup
+ $db->Execute("delete from photos where id=99 or id=1");
+ $db->Execute("insert into photos (id) values(1)");
+ $db->Execute("update photos set photo=null,descclob=null where id=1");
+
$saved = $db->debug;
$db->debug=true;
+
/*
CREATE TABLE PHOTOS
@@ -427,7 +447,25 @@ GO
$s .= '1234567890';
}
+ $sql = "INSERT INTO photos ( ID, photo) ".
+ "VALUES ( :id, empty_blob() )".
+ " RETURNING photo INTO :xx";
+
+ $blob_data = $s;
+ $id = 99;
+
+ $stmt = $db->PrepareSP($sql);
+ $db->InParameter($stmt, $id, 'id');
+ $blob = $db->InParameter($stmt, $s, 'xx',-1, OCI_B_BLOB);
+ $db->StartTrans();
+ $result = $db->Execute($stmt);
+ $db->CompleteTrans();
+
+ $s2= $db->GetOne("select photo from photos where id=99");
+ echo " ---$s2";
+ if ($s !== $s2) Err("insert blob does not match");
+
print "
Testing Blob: size=".strlen($s)." ";
$ok = $db->Updateblob('photos','photo',$s,'id=1');
if (!$ok) Err("Blob failed 1");
@@ -451,16 +489,17 @@ GO
$arr = $db->MetaForeignKeys('emp');
print_r($arr);
if (!$arr) Err("Bad MetaForeignKeys");
- print "Testing Cursor Variables ";
/*
-- TEST PACKAGE
+-- "Set scan off" turns off substitution variables.
+Set scan off;
CREATE OR REPLACE PACKAGE Adodb AS
TYPE TabType IS REF CURSOR RETURN TAB%ROWTYPE;
PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames IN VARCHAR);
PROCEDURE open_tab2 (tabcursor IN OUT TabType,tablenames IN OUT VARCHAR) ;
PROCEDURE data_out(input IN VARCHAR, output OUT VARCHAR);
-
+PROCEDURE data_in(input IN VARCHAR);
PROCEDURE myproc (p1 IN NUMBER, p2 OUT NUMBER);
END Adodb;
/
@@ -477,11 +516,17 @@ PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames IN VARCHAR) IS
OPEN tabcursor FOR SELECT * FROM TAB WHERE tname LIKE tablenames;
tablenames := 'TEST';
END open_tab2;
-
+
PROCEDURE data_out(input IN VARCHAR, output OUT VARCHAR) IS
BEGIN
output := 'Cinta Hati '||input;
END;
+
+PROCEDURE data_in(input IN VARCHAR) IS
+ ignore varchar(1000);
+ BEGIN
+ ignore := input;
+ END;
PROCEDURE myproc (p1 IN NUMBER, p2 OUT NUMBER) AS
BEGIN
@@ -490,8 +535,9 @@ END;
END Adodb;
/
-
*/
+
+ print "Testing Cursor Variables ";
$rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:zz,'A%'); END;",'zz');
if ($rs && !$rs->EOF) {
@@ -501,6 +547,7 @@ END Adodb;
} else {
print "Error in using Cursor Variables 1 ";
}
+ $rs->Close();
print "
Testing Stored Procedures for oci8 ";
@@ -517,7 +564,6 @@ END Adodb;
print "Error in using Stored Procedure IN/Out Variables ";
}
-
$tname = 'A%';
$stmt = $db->PrepareSP('select * from tab where tname like :tablename');
@@ -525,6 +571,10 @@ END Adodb;
$rs = $db->Execute($stmt);
rs2html($rs);
+ $stmt = $db->PrepareSP("begin adodb.data_in(:a1); end;");
+ $db->InParameter($stmt,$a1,'a1');
+ $db->Execute($stmt);
+
$db->debug = $saved;
break;
@@ -577,7 +627,8 @@ END Adodb;
$arr = array(0=>'Caroline',1=>'Miranda');
$sql = "insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+0,?,?,$time)";
break;
-
+ case 'mysqli':
+ case 'mysqlt':
case 'mysql':
$sqlt = "CREATE TABLE `mytable` (
`row1` int(11) NOT NULL auto_increment,
@@ -644,17 +695,15 @@ END Adodb;
else if ($nrows != $cnt) print "
Affected_Rows() Error: $nrows returned (should be 50)
";
else print "Affected_Rows() passed
";
}
-
-
+
$array = array('zid'=>1,'zdate'=>date('Y-m-d',time()));
$id = $db->GetOne("select id from ADOXYZ
where id=".$db->Param('zid')." and created>=".$db->Param('ZDATE')."",
$array);
if ($id != 1) Err("Bad bind; id=$id");
- else echo " Bind date/integer passed";
+ else echo " Bind date/integer passed";
$db->debug = false;
-
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
//////////////////////////////////////////////////////////////////////////////////////////
@@ -735,6 +784,7 @@ END Adodb;
}
if ($rs->fields['id'] != 1) {Err("Error"); print_r($rs->fields);};
if (trim($rs->fields['firstname']) != 'Caroline') {print Err("Error 2"); print_r($rs->fields);};
+
$rs->MoveNext();
if ($rs->fields['id'] != 2) {Err("Error 3"); print_r($rs->fields);};
$rs->MoveNext();
@@ -805,28 +855,28 @@ END Adodb;
if (trim($col[0]) != 'Alan' or trim($col[9]) != 'Yat Sun') Err("Col elements wrong");
$db->debug = true;
- print "SelectLimit Distinct Test 1: Should see Caroline, John and Mary
";
- $rs = &$db->SelectLimit('select distinct * from ADOXYZ order by id',3);
+
echo "Date Update Test
";
$zdate = date('Y-m-d',time()+3600*24);
$zdate = $db->DBDate($zdate);
$db->Execute("update ADOXYZ set created=$zdate where id=1");
$row = $db->GetRow("select created,firstname from ADOXYZ where id=1");
- print_r($row); echo " ";
+ print_r($row); echo " ";
+
+
+
+ print "SelectLimit Distinct Test 1: Should see Caroline, John and Mary
";
+ $rs = &$db->SelectLimit('select distinct * from ADOXYZ order by id',3);
- //$zdate = date('Y-m-d',time()+3600*24);
- //$db->Execute("update ADOXYZ set created=? where id=2",$zdate);
- //$zdate = $db->GetOne("select created from ADOXYZ where id=2");
- //echo "tomorrow=",$zdate," ";
- $db->debug=false;
if ($rs && !$rs->EOF) {
- if (trim($rs->fields[1]) != 'Caroline') Err("Error 1");
+ if (trim($rs->fields[1]) != 'Caroline') Err("Error 1 (exp Caroline), ".$rs->fields[1]);
$rs->MoveNext();
- if (trim($rs->fields[1]) != 'John') Err("Error 2");
+
+ if (trim($rs->fields[1]) != 'John') Err("Error 2 (exp John), ".$rs->fields[1]);
$rs->MoveNext();
- if (trim($rs->fields[1]) != 'Mary') Err("Error 3");
+ if (trim($rs->fields[1]) != 'Mary') Err("Error 3 (exp Mary),".$rs->fields[1]);
$rs->MoveNext();
if (! $rs->EOF) Err("Error EOF");
//rs2html($rs);
@@ -835,16 +885,16 @@ END Adodb;
print "SelectLimit Test 2: Should see Mary, George and Mr. Alan
";
$rs = &$db->SelectLimit('select * from ADOXYZ order by id',3,2);
if ($rs && !$rs->EOF) {
- if (trim($rs->fields[1]) != 'Mary') Err("Error 1");
+ if (trim($rs->fields[1]) != 'Mary') Err("Error 1 - No Mary, instead: ".$rs->fields[1]);
$rs->MoveNext();
- if (trim($rs->fields[1]) != 'George')Err("Error 2");
+ if (trim($rs->fields[1]) != 'George')Err("Error 2 - No George, instead: ".$rs->fields[1]);
$rs->MoveNext();
- if (trim($rs->fields[1]) != 'Mr. Alan') Err("Error 3");
+ if (trim($rs->fields[1]) != 'Mr. Alan') Err("Error 3 - No Mr. Alan, instead: ".$rs->fields[1]);
$rs->MoveNext();
if (! $rs->EOF) Err("Error EOF");
// rs2html($rs);
}
- else Err("Failed SelectLimit Test 2");
+ else Err("Failed SelectLimit Test 2 ". ($rs ? 'EOF':'no RS'));
print "SelectLimit Test 3: Should see Wai Hun and Steven
";
$db->debug=1;
@@ -878,25 +928,25 @@ END Adodb;
if (trim($rs->Fields("firstname")) != 'Caroline') {
print "$db->databaseType: MoveFirst failed -- probably cannot scroll backwards
";
}
- else print "MoveFirst() OK ";
+ else print "MoveFirst() OK ";
// Move(3) tests error handling -- MoveFirst should not move cursor
$rs->Move(3);
if (trim($rs->Fields("firstname")) != 'George') {
print ''.$rs->Fields("id")."$db->databaseType: Move(3) failed
";
- } else print "Move(3) OK ";
+ } else print "Move(3) OK ";
$rs->Move(7);
if (trim($rs->Fields("firstname")) != 'Yat Sun') {
print ''.$rs->Fields("id")."$db->databaseType: Move(7) failed
";
print_r($rs);
- } else print "Move(7) OK ";
+ } else print "Move(7) OK ";
if ($rs->EOF) Err("Move(7) is EOF already");
$rs->MoveLast();
if (trim($rs->Fields("firstname")) != 'Steven'){
print ''.$rs->Fields("id")."$db->databaseType: MoveLast() failed
";
print_r($rs);
- }else print "MoveLast() OK ";
+ }else print "MoveLast() OK ";
$rs->MoveNext();
if (!$rs->EOF) err("Bad MoveNext");
if ($rs->canSeek) {
@@ -904,7 +954,7 @@ END Adodb;
if (trim($rs->Fields("firstname")) != 'George') {
print ''.$rs->Fields("id")."$db->databaseType: Move(3) after MoveLast failed
";
- } else print "Move(3) after MoveLast() OK ";
+ } else print "Move(3) after MoveLast() OK ";
}
print "Empty Move Test";
@@ -942,13 +992,13 @@ END Adodb;
$rs = &$db->Execute("select * from ADOXYZ order by id");
if ($rs) {
$arr = &$rs->GetArray(10);
- if (sizeof($arr) != 10 || trim($arr[1][1]) != 'John' || trim($arr[1][2]) != 'Lim') print $arr[1][1].' '.$arr[1][2]." ERROR ";
- else print " OK ";
+ if (sizeof($arr) != 10 || trim($arr[1][1]) != 'John' || trim($arr[1][2]) != 'Lim') print $arr[1][1].' '.$arr[1][2]." ERROR ";
+ else print " OK ";
}
$arr = $db->GetArray("select x from ADOXYZ");
$e = $db->ErrorMsg(); $e2 = $db->ErrorNo();
- echo "Testing error handling, should see illegal column 'x' error=$e ($e2) ";
+ echo "Testing error handling, should see illegal column 'x' error=$e ($e2) ";
if (!$e || !$e2) Err("Error handling did not work");
print "Testing FetchNextObject for 1 object ";
$rs = &$db->Execute("select distinct lastname,firstname from ADOXYZ where firstname='Caroline'");
@@ -957,8 +1007,8 @@ END Adodb;
while ($o = $rs->FetchNextObject()) {
$fcnt += 1;
}
- if ($fcnt == 1) print " OK ";
- else print "FAILED ";
+ if ($fcnt == 1) print " OK ";
+ else print "FAILED ";
$stmt = $db->Prepare("select * from ADOXYZ where id < 3");
$rs = $db->Execute($stmt);
@@ -979,54 +1029,65 @@ END Adodb;
if ($rs) {
$arr = $rs->GetAssoc();
//print_r($arr);
- if (empty($arr['See']) || trim(reset($arr['See'])) != 'Wai Hun') print $arr['See']." ERROR ";
+ if (empty($arr['See']) || trim(reset($arr['See'])) != 'Wai Hun') print $arr['See']." ERROR ";
else print " OK 1";
}
$arr = &$db->GetAssoc("select distinct lastname,firstname from ADOXYZ");
if ($arr) {
//print_r($arr);
- if (empty($arr['See']) || trim($arr['See']) != 'Wai Hun') print $arr['See']." ERROR ";
- else print " OK 2 ";
+ if (empty($arr['See']) || trim($arr['See']) != 'Wai Hun') print $arr['See']." ERROR ";
+ else print " OK 2 ";
}
// Comment this out to test countrecs = false
$ADODB_COUNTRECS = $savecrecs;
for ($loop=0; $loop < 1; $loop++) {
- print "Testing GetMenu() and CacheExecute ";
+ print "Testing GetMenu() and CacheExecute ";
$db->debug = true;
$rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ");
- if ($rs) print 'With blanks, Steven selected:'. $rs->GetMenu('menu','Steven').' ';
- else print " Fail ";
+ if ($rs) print 'With blanks, Steven selected:'. $rs->GetMenu('menu','Steven').' ';
+ else print " Fail ";
$rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ");
- if ($rs) print ' No blanks, Steven selected: '. $rs->GetMenu('menu','Steven',false).' ';
- else print " Fail ";
+ if ($rs) print ' No blanks, Steven selected: '. $rs->GetMenu('menu','Steven',false).' ';
+ else print " Fail ";
$rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ");
- if ($rs) print ' Multiple, Alan selected: '. $rs->GetMenu('menu','Alan',false,true).' ';
- else print " Fail ";
+ if ($rs) print ' Multiple, Alan selected: '. $rs->GetMenu('menu','Alan',false,true).' ';
+ else print " Fail ";
print '
';
$rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ");
if ($rs) {
print ' Multiple, Alan and George selected: '. $rs->GetMenu('menu',array('Alan','George'),false,true);
if (empty($rs->connection)) print "Connection object missing from recordset ";
- } else print " Fail ";
+ } else print " Fail ";
print '
';
- print "Testing GetMenu2() ";
+ print "Testing GetMenu2() ";
$rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ");
- if ($rs) print 'With blanks, Steven selected:'. $rs->GetMenu2('menu',('Oey')).' ';
- else print " Fail ";
- $rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ");
- if ($rs) print ' No blanks, Steven selected: '. $rs->GetMenu2('menu',('Oey'),false).' ';
- else print " Fail ";
+ if ($rs) print 'With blanks, Steven selected:'. $rs->GetMenu2('menu',('Oey')).' ';
+ else print " Fail ";
+ $rs = &$db->CacheExecute(6,"select distinct firstname,lastname from ADOXYZ");
+ if ($rs) print ' No blanks, Steven selected: '. $rs->GetMenu2('menu',('Oey'),false).' ';
+ else print " Fail ";
}
+ echo "CacheEXecute ";
+
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $rs = &$db->CacheExecute(6,"select distinct firstname,lastname from ADOXYZ");
+ print_r($rs->fields); echo $rs->fetchMode;echo " ";
+ echo $rs->Fields('firstname');
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ $rs = &$db->CacheExecute(6,"select distinct firstname,lastname from ADOXYZ");
+ print_r($rs->fields);echo " ";
+ echo $rs->Fields('firstname');
$db->debug = false;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
// phplens
$sql = 'select * from ADOXYZ where 0=1';
@@ -1039,13 +1100,13 @@ END Adodb;
$sql = 'select * from ADOXYZ order by 1';
echo "**Testing '$sql' (phplens compat 2)
";
$rs = &$db->Execute($sql);
- if (!$rs) err( "No recordset returned for '$sql' ".$db->ErrorMsg()." ");
+ if (!$rs) err( "No recordset returned for '$sql' ".$db->ErrorMsg()." ");
$sql = 'select * from ADOXYZ order by 1,1';
echo "**Testing '$sql' (phplens compat 3)
";
$rs = &$db->Execute($sql);
- if (!$rs) err( "No recordset returned for '$sql' ".$db->ErrorMsg()." ");
+ if (!$rs) err( "No recordset returned for '$sql' ".$db->ErrorMsg()." ");
// Move
@@ -1089,7 +1150,7 @@ END Adodb;
} else
print "ADO skipped error handling of bad select statement
";
- print "ASSOC TEST 2 ";
+ print "
ASSOC TEST 2 ";
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$rs = $db->query('select * from adoxyz order by id');
if ($ee = $db->ErrorMsg()) {
@@ -1102,48 +1163,48 @@ END Adodb;
for($i=0;$i<$rs->FieldCount();$i++)
{
$fld=$rs->FetchField($i);
- print " Field name is ".$fld->name;
+ print " Field name is ".$fld->name;
print " ".$rs->Fields($fld->name);
}
- print "
BOTH TEST 2 ";
+ print "
BOTH TEST 2 ";
if ($db->dataProvider == 'ado') {
- print "ADODB_FETCH_BOTH not supported for dataProvider=".$db->dataProvider." ";
+ print "ADODB_FETCH_BOTH not supported for dataProvider=".$db->dataProvider." ";
} else {
$ADODB_FETCH_MODE = ADODB_FETCH_BOTH;
$rs = $db->query('select * from adoxyz order by id');
for($i=0;$i<$rs->FieldCount();$i++)
{
$fld=$rs->FetchField($i);
- print " Field name is ".$fld->name;
+ print " Field name is ".$fld->name;
print " ".$rs->Fields($fld->name);
}
}
- print "
NUM TEST 2 ";
+ print "
NUM TEST 2 ";
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$rs = $db->query('select * from adoxyz order by id');
for($i=0;$i<$rs->FieldCount();$i++)
{
$fld=$rs->FetchField($i);
- print " Field name is ".$fld->name;
+ print " Field name is ".$fld->name;
print " ".$rs->Fields($fld->name);
}
- print "
ASSOC Test of SelectLimit ";
+ print "
ASSOC Test of SelectLimit ";
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$rs = $db->selectlimit('select * from adoxyz order by id',3,4);
$cnt = 0;
while ($rs && !$rs->EOF) {
$cnt += 1;
if (!isset($rs->fields['firstname'])) {
- print "ASSOC returned numeric field
";
+ print "ASSOC returned numeric field
";
break;
}
$rs->MoveNext();
}
- if ($cnt != 3) print "Count should be 3, instead it was $cnt ";
+ if ($cnt != 3) print "Count should be 3, instead it was $cnt ";
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
@@ -1188,7 +1249,7 @@ END Adodb;
$rs = $db->SelectLimit($sql,1);
$d = date('d-m-M-Y-').'Q'.(ceil(date('m')/3.0)).date(' h:i:s A');
if (!$rs) Err("SQLDate query returned no recordset");
- else if ($d != $rs->fields[0]) Err("SQLDate 1 failed expected: act:$d sql:".$rs->fields[0]);
+ else if ($d != $rs->fields[0]) Err("SQLDate 1 failed expected: act:$d sql:".$rs->fields[0]);
$date = $db->SQLDate('d-m-M-Y-\QQ h:i:s A',$db->DBDate("1974-02-25"));
$sql = "SELECT $date from ADOXYZ";
@@ -1197,7 +1258,7 @@ END Adodb;
$ts = ADOConnection::UnixDate('1974-02-25');
$d = date('d-m-M-Y-',$ts).'Q'.(ceil(date('m',$ts)/3.0)).date(' h:i:s A',$ts);
if (!$rs) Err("SQLDate query returned no recordset");
- else if ($d != $rs->fields[0]) Err("SQLDate 2 failed expected: act:$d sql:".$rs->fields[0]);
+ else if ($d != $rs->fields[0]) Err("SQLDate 2 failed expected: act:$d sql:".$rs->fields[0]);
print "Test Filter
";
@@ -1255,13 +1316,13 @@ END Adodb;
print "rs2rs Test ";
- $rs = $db->Execute('select * from adoxyz order by id');
+ $rs = $db->Execute('select * from adoxyz where id>= 1 order by id');
$rs = $db->_rs2rs($rs);
$rs->valueX = 'X';
$rs->MoveNext();
$rs = $db->_rs2rs($rs);
if (!isset($rs->valueX)) err("rs2rs does not preserve array recordsets");
- if (reset($rs->fields) != 1) err("rs2rs does not move to first row");
+ if (reset($rs->fields) != 1) err("rs2rs does not move to first row: id=".reset($rs->fields));
/////////////////////////////////////////////////////////////
include_once('../pivottable.inc.php');
@@ -1413,7 +1474,7 @@ END Adodb;
$metae = $db->MetaError($ERRNO);
if ($metae !== DB_ERROR_NOSUCHTABLE) print "MetaError=".$metae." wrong , should be ".DB_ERROR_NOSUCHTABLE."
";
else print "MetaError ok (".DB_ERROR_NOSUCHTABLE."): ".$db->MetaErrorMsg($metae)."
";
- if ($TESTERRS != 1) print "raiseErrorFn select nowhere failed ";
+ if ($TESTERRS != 1) print "raiseErrorFn select nowhere failed ";
$rs = $db->Execute('select * from adoxyz');
if ($debugerr) print " Move";
$rs->Move(100);
@@ -1446,11 +1507,12 @@ END Adodb;
print "";
////////////////////////////////////////////////////////////////////
+ if ($db->dataProvider == 'odbtp') $db->databaseType = 'odbtp';
$conn = NewADOConnection($db->databaseType);
$conn->raiseErrorFn = 'adodb_test_err';
@$conn->PConnect('abc');
- if ($TESTERRS == 2) print "raiseErrorFn tests passed ";
- else print "raiseErrorFn tests failed ($TESTERRS) ";
+ if ($TESTERRS == 2) print "raiseErrorFn tests passed ";
+ else print "raiseErrorFn tests failed ($TESTERRS) ";
////////////////////////////////////////////////////////////////////
@@ -1484,7 +1546,7 @@ global $TESTERRS,$ERRNO;
$ERRNO = $errno;
$TESTERRS += 1;
- print "** $dbms ($fn): errno=$errno errmsg=$errmsg ($p1,$p2) ";
+ print "** $dbms ($fn): errno=$errno errmsg=$errmsg ($p1,$p2) ";
}
//--------------------------------------------------------------------------------------
@@ -1557,12 +1619,13 @@ Test GetInsertSQL/GetUpdateSQL
vers=",ADOConnection::Version();
+echo " vers=",ADOConnection::Version();
include_once('../adodb-time.inc.php');
-if (!isset($_GET['nd'])) adodb_date_test();
+if (isset($_GET['time'])) adodb_date_test();
+
?>
-
ADODB Database Library (c) 2000-2004 John Lim. All rights reserved. Released under BSD and LGPL.
+ADODB Database Library (c) 2000-2005 John Lim. All rights reserved. Released under BSD and LGPL.