From: moodler
Date: Sat, 7 Aug 2004 14:10:19 +0000 (+0000)
Subject: Upgraded to ADOdb 4.5.1. Contains a lot of small fixes and speed-ups.
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=fab7e07e19490b12b925356394b3fc15ef0812b4;p=moodle.git
Upgraded to ADOdb 4.5.1. Contains a lot of small fixes and speed-ups.
---
diff --git a/lib/adodb/adodb-csvlib.inc.php b/lib/adodb/adodb-csvlib.inc.php
index 05f90291fd..63cb4a51a5 100644
--- a/lib/adodb/adodb-csvlib.inc.php
+++ b/lib/adodb/adodb-csvlib.inc.php
@@ -7,7 +7,7 @@ global $ADODB_INCLUDED_CSV;
$ADODB_INCLUDED_CSV = 1;
/*
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
+ V4.51 29 July 2004 (c) 2000-2004 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.
@@ -249,4 +249,56 @@ $ADODB_INCLUDED_CSV = 1;
$rs->InitArrayFields($arr,$flds);
return $rs;
}
+
+
+ /**
+ * Save a file $filename and its $contents (normally for caching) with file locking
+ */
+ function adodb_write_file($filename, $contents,$debug=false)
+ {
+ # http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows
+ # So to simulate locking, we assume that rename is an atomic operation.
+ # First we delete $filename, then we create a $tempfile write to it and
+ # rename to the desired $filename. If the rename works, then we successfully
+ # modified the file exclusively.
+ # What a stupid need - having to simulate locking.
+ # Risks:
+ # 1. $tempfile name is not unique -- very very low
+ # 2. unlink($filename) fails -- ok, rename will fail
+ # 3. adodb reads stale file because unlink fails -- ok, $rs timeout occurs
+ # 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated
+ if (strncmp(PHP_OS,'WIN',3) === 0) {
+ // skip the decimal place
+ $mtime = substr(str_replace(' ','_',microtime()),2);
+ // getmypid() actually returns 0 on Win98 - never mind!
+ $tmpname = $filename.uniqid($mtime).getmypid();
+ if (!($fd = fopen($tmpname,'a'))) return false;
+ $ok = ftruncate($fd,0);
+ if (!fwrite($fd,$contents)) $ok = false;
+ fclose($fd);
+ chmod($tmpname,0644);
+ // the tricky moment
+ @unlink($filename);
+ if (!@rename($tmpname,$filename)) {
+ unlink($tmpname);
+ $ok = false;
+ }
+ if (!$ok) {
+ if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed'));
+ }
+ return $ok;
+ }
+ if (!($fd = fopen($filename, 'a'))) return false;
+ if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) {
+ $ok = fwrite( $fd, $contents );
+ fclose($fd);
+ chmod($filename,0644);
+ }else {
+ fclose($fd);
+ if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename
\n");
+ $ok = false;
+ }
+
+ return $ok;
+ }
?>
\ No newline at end of file
diff --git a/lib/adodb/adodb-datadict.inc.php b/lib/adodb/adodb-datadict.inc.php
index 453eb329be..4963fca4f8 100644
--- a/lib/adodb/adodb-datadict.inc.php
+++ b/lib/adodb/adodb-datadict.inc.php
@@ -1,7 +1,7 @@
rs, $func), $params);
}
-
- function __toString()
- {
- if (isset($rs->databaseType)) $s = ' for '.$rs->databaseType;
- else $s = '';
-
- return 'ADODB Iterator'.$s;
- }
+
function hasMore()
{
@@ -79,6 +72,12 @@ class ADODB_BASE_RS implements IteratorAggregate {
function getIterator() {
return new ADODB_Iterator($this);
}
+
+ function __toString()
+ {
+ include_once(ADODB_DIR.'/toexport.inc.php');
+ return _adodb_export($this,',',',',false,true);
+ }
}
?>
\ No newline at end of file
diff --git a/lib/adodb/adodb-lib.inc.php b/lib/adodb/adodb-lib.inc.php
index 2d0a5d6d7d..6366301837 100644
--- a/lib/adodb/adodb-lib.inc.php
+++ b/lib/adodb/adodb-lib.inc.php
@@ -63,7 +63,7 @@ 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) {
/*
@@ -77,8 +77,10 @@ function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_
$cnt = $zthis->GetOne("select count(*) from $table where $where");
if ($cnt > 0) return 1; // record already exists
- } else
- if (($zthis->Affected_Rows()>0)) return 1;
+ } else {
+
+ if (($zthis->Affected_Rows()>0)) return 1;
+ }
}
}
// print "Error=".$this->ErrorNo().'
';
@@ -96,7 +98,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;
}
@@ -216,7 +218,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) {
@@ -266,11 +268,7 @@ function &_adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page,
$lastpageno = (int) ceil($qryRecs / $nrows);
$zthis->_maxRecordCount = $qryRecs;
- // If page number <= 1, then we are at the first page
- if (!isset($page) || $page <= 1) {
- $page = 1;
- $atfirstpage = true;
- }
+
// ***** Here we check whether $page is the last page or
// whether we are trying to retrieve
@@ -280,6 +278,12 @@ function &_adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page,
$atlastpage = true;
}
+ // If page number <= 1, then we are at the first page
+ if (empty($page) || $page <= 1) {
+ $page = 1;
+ $atfirstpage = true;
+ }
+
// We get the data we want
$offset = $nrows * ($page-1);
if ($secs2cache > 0)
@@ -372,7 +376,7 @@ 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)) {
+ if (adodb_key_exists($upperfname,$arrFields,$forcenulls)) {
// If the existing field value in the recordset
// is different from the value passed in then
@@ -392,31 +396,32 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq
// Based on the datatype of the field
// 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';
+ $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;
+
+ //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
+ //postgres has special needs as well
+ $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq,
+ $arrFields, $magicq);
}
-
- if (strpos($upperfname,' ') !== false)
- $fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote;
- else
- $fnameq = $upperfname;
- //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
- //postgres has special needs as well
- $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq,
- $arrFields, $magicq);
}
}
}
- }
// If there were any modified fields then build the rest of the update query.
if ($fieldUpdatedCount > 0 || $forceUpdate) {
@@ -429,9 +434,10 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq
$discard = false;
// not a good hack, improvements?
- if ($whereClause)
- preg_match('/\s(LIMIT\s.*)/is', $whereClause[1], $discard);
- else
+ if ($whereClause) {
+ if (preg_match('/\s(ORDER\s.*)/is', $whereClause[1], $discard));
+ else preg_match('/\s(LIMIT\s.*)/is', $whereClause[1], $discard);
+ } else
$whereClause = array(false,false);
if ($discard)
@@ -503,7 +509,7 @@ 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)) {
+ if (adodb_key_exists($upperfname,$arrFields,$forcenulls)) {
// Set the counter for the number of fields that will be inserted.
$fieldInsertedCount++;
@@ -539,8 +545,10 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$forcenulls=f
// Get the table name from the existing query.
if (!$tableName) {
- preg_match("/FROM\s+".ADODB_TABLE_REGEX."/is", $rs->sql, $tableName);
+ if (preg_match("/FROM\s+".ADODB_TABLE_REGEX."/is", $rs->sql, $tableName))
$tableName = $tableName[1];
+ else
+ return false;
}
// Strip off the comma and space on the end of both the fields
@@ -693,4 +701,105 @@ function _adodb_column_sql(&$zthis, $action, $type, $fname, $fnameq, $arrFields,
return $sql;
}
+
+
+
+function _adodb_debug_execute(&$zthis, $sql, $inputarr)
+{
+global $HTTP_SERVER_VARS;
+
+ $ss = '';
+ if ($inputarr) {
+ foreach($inputarr as $kk=>$vv) {
+ if (is_string($vv) && strlen($vv)>64) $vv = substr($vv,0,64).'...';
+ $ss .= "($kk=>'$vv') ";
+ }
+ $ss = "[ $ss ]";
+ }
+ $sqlTxt = str_replace(',',', ',is_array($sql) ? $sql[0] : $sql);
+
+ // check if running from browser or command-line
+ $inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']);
+
+ if ($inBrowser) {
+ $ss = htmlspecialchars($ss);
+ if ($zthis->debug === -1)
+ ADOConnection::outp( "
\n($zthis->databaseType): ".htmlspecialchars($sqlTxt)." $ss
\n
\n",false);
+ else
+ ADOConnection::outp( "
\n($zthis->databaseType): ".htmlspecialchars($sqlTxt)." $ss
\n
\n",false);
+ } else {
+ ADOConnection::outp("-----\n($zthis->databaseType): ".$sqlTxt."\n-----\n",false);
+ }
+
+ $qID = $zthis->_query($sql,$inputarr);
+
+ /*
+ Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql
+ because ErrorNo() calls Execute('SELECT @ERROR'), causing recursion
+ */
+ if ($zthis->databaseType == 'mssql') {
+ // ErrorNo is a slow function call in mssql, and not reliable in PHP 4.0.6
+ if($emsg = $zthis->ErrorMsg()) {
+ if ($err = $zthis->ErrorNo()) ADOConnection::outp($err.': '.$emsg);
+ }
+ } else if (!$qID) {
+ ADOConnection::outp($zthis->ErrorNo() .': '. $zthis->ErrorMsg());
+ }
+
+ return $qID;
+}
+
+
+function _adodb_backtrace($printOrArr=true,$levels=9999)
+{
+ if (PHPVERSION() < 4.3) return '';
+
+ $html = (isset($_SERVER['HTTP_USER_AGENT']));
+ $fmt = ($html) ? " %% line %4d, file: %s" : "%% line %4d, file: %s";
+
+ $MAXSTRLEN = 64;
+
+ $s = ($html) ? '' : '';
+
+ if (is_array($printOrArr)) $traceArr = $printOrArr;
+ else $traceArr = debug_backtrace();
+ array_shift($traceArr);
+ array_shift($traceArr);
+ $tabs = sizeof($traceArr)-2;
+
+ foreach ($traceArr as $arr) {
+ $levels -= 1;
+ if ($levels < 0) break;
+
+ $args = array();
+ for ($i=0; $i < $tabs; $i++) $s .= ($html) ? ' ' : "\t";
+ $tabs -= 1;
+ if ($html) $s .= '';
+ if (isset($arr['class'])) $s .= $arr['class'].'.';
+ if (isset($arr['args']))
+ foreach($arr['args'] as $v) {
+ if (is_null($v)) $args[] = 'null';
+ else if (is_array($v)) $args[] = 'Array['.sizeof($v).']';
+ else if (is_object($v)) $args[] = 'Object:'.get_class($v);
+ else if (is_bool($v)) $args[] = $v ? 'true' : 'false';
+ else {
+ $v = (string) @$v;
+ $str = htmlspecialchars(substr($v,0,$MAXSTRLEN));
+ if (strlen($v) > $MAXSTRLEN) $str .= '...';
+ $args[] = $str;
+ }
+ }
+ $s .= $arr['function'].'('.implode(', ',$args).')';
+
+
+ $s .= @sprintf($fmt, $arr['line'],$arr['file'],basename($arr['file']));
+
+ $s .= "\n";
+ }
+ if ($html) $s .= '
';
+ if ($printOrArr) print $s;
+
+ return $s;
+}
+
?>
\ No newline at end of file
diff --git a/lib/adodb/adodb-pager.inc.php b/lib/adodb/adodb-pager.inc.php
index 7250e728ad..09caa2671d 100644
--- a/lib/adodb/adodb-pager.inc.php
+++ b/lib/adodb/adodb-pager.inc.php
@@ -1,7 +1,7 @@
db->pageExecuteCountRows) return '';
$lastPage = $this->rs->LastPageNo();
if ($lastPage == -1) $lastPage = 1; // check for empty rs.
+ if ($this->curr_page > $lastPage) $this->curr_page = 1;
return "$this->page ".$this->curr_page."/".$lastPage."";
}
diff --git a/lib/adodb/adodb-perf.inc.php b/lib/adodb/adodb-perf.inc.php
index 5a99d15fc9..7c1ee77d9e 100644
--- a/lib/adodb/adodb-perf.inc.php
+++ b/lib/adodb/adodb-perf.inc.php
@@ -1,6 +1,6 @@
- ADOdb Performance Monitor for $app |
+ ADOdb Performance Monitor for $app |
Performance Stats View SQL
View Tables Poll Stats",
$allowsql ? ' Run SQL' : '',
diff --git a/lib/adodb/adodb-php4.inc.php b/lib/adodb/adodb-php4.inc.php
index 1524d4fa02..13925b5632 100644
--- a/lib/adodb/adodb-php4.inc.php
+++ b/lib/adodb/adodb-php4.inc.php
@@ -1,7 +1,7 @@
';
+
$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).' ';
@@ -428,7 +435,7 @@ function adodb_date_test()
// we generate a timestamp, convert it to a date, and convert it back to a timestamp
// and check if the roundtrip broke the original timestamp value.
print "Testing $start to ".($start+$yrs).", or $max seconds, offset=$offset: ";
-
+ $cnt = 0;
for ($max += $i; $i < $max; $i += $offset) {
$ret = adodb_date('m,d,Y,H,i,s',$i);
$arr = explode(',',$ret);
@@ -443,8 +450,9 @@ function adodb_date_test()
$fail = true;
break;
}
+ $cnt += 1;
}
-
+ echo "Tested $cnt dates ";
if (!$fail) print "Passed ! ";
else print "Failed :-( ";
}
@@ -717,6 +725,8 @@ function adodb_date2($fmt, $d=false, $is_gmt=false)
*/
function adodb_date($fmt,$d=false,$is_gmt=false)
{
+static $daylight;
+
if ($d === false) return ($is_gmt)? @gmdate($fmt): @date($fmt);
if (!defined('ADODB_TEST_DATES')) {
if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
@@ -728,7 +738,8 @@ function adodb_date($fmt,$d=false,$is_gmt=false)
$_day_power = 86400;
$arr = _adodb_getdate($d,true,$is_gmt);
- if (function_exists('adodb_daylight_sv')) adodb_daylight_sv($arr, $is_gmt);
+ if (!isset($daylight)) $daylight = function_exists('adodb_daylight_sv');
+ if ($daylight) adodb_daylight_sv($arr, $is_gmt);
$year = $arr['year'];
$month = $arr['mon'];
@@ -852,7 +863,7 @@ function adodb_date($fmt,$d=false,$is_gmt=false)
Returns a timestamp given a GMT/UTC time.
Note that $is_dst is not implemented and is ignored.
*/
-function adodb_gmmktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false)
+function adodb_gmmktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false)
{
return adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst,true);
}
@@ -863,13 +874,15 @@ function adodb_gmmktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false)
Not a very fast algorithm - O(n) operation. Could be optimized to O(1).
*/
-function adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false,$is_gmt=false)
+function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false,$is_gmt=false)
{
if (!defined('ADODB_TEST_DATES')) {
// for windows, we don't check 1970 because with timezone differences,
// 1 Jan 1970 could generate negative timestamp, which is illegal
- if (!defined('ADODB_NO_NEGATIVE_TS') || ($year >= 1971))
- if (1901 < $year && $year < 2038)
+ if (1971 < $year && $year < 2038
+ || $mon === false
+ || !defined('ADODB_NO_NEGATIVE_TS') && (1901 < $year && $year < 2038)
+ )
return $is_gmt?
@gmmktime($hr,$min,$sec,$mon,$day,$year):
@mktime($hr,$min,$sec,$mon,$day,$year);
diff --git a/lib/adodb/adodb-xmlschema.inc.php b/lib/adodb/adodb-xmlschema.inc.php
index 9c9932afa7..a395de7074 100644
--- a/lib/adodb/adodb-xmlschema.inc.php
+++ b/lib/adodb/adodb-xmlschema.inc.php
@@ -4,31 +4,6 @@
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.
-
-Redistribution and use in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
-Redistributions of source code must retain the above copyright notice, this list
- of conditions and the following disclaimer.
-Redistributions in binary form must reproduce the above copyright notice, this l
-ist of conditions and the following disclaimer in the documentation and/or other
- materials provided with the distribution.
-Neither the name of the ars Cognita, Inc., nor the names of its contributors may be used
-to endorse or promote products derived from this software without specific prior
-written permission.
-
-DISCLAIMER:
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WA
-RRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIREC
-T, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR P
-ROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWI
-SE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE P
-OSSIBILITY OF SUCH DAMAGE.
-
*******************************************************************************/
/**
* xmlschema is a class that allows the user to quickly and easily
@@ -104,6 +79,7 @@ if( !defined( 'XMLS_DEFAULT_UPGRADE_METHOD' ) ) {
*/
if( !defined( '_ADODB_LAYER' ) ) {
require( 'adodb.inc.php' );
+ require( 'adodb-datadict.inc.php' );
}
/**
@@ -274,7 +250,14 @@ class dbTable extends dbObject {
switch( $this->currentElement ) {
case 'INDEX':
- xml_set_object( $parser, $this->addIndex( $attributes ) );
+ if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
+ xml_set_object( $parser, $this->addIndex( $attributes ) );
+ }
+ break;
+ case 'DATA':
+ if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
+ xml_set_object( $parser, $this->addData( $attributes ) );
+ }
break;
case 'DROP':
$this->drop();
@@ -288,7 +271,7 @@ class dbTable extends dbObject {
$this->addField( $fieldName, $fieldType, $fieldSize, $fieldOpts );
break;
- case 'KEY':
+ case 'KEY':
case 'NOTNULL':
case 'AUTOINCREMENT':
// Add a field option
@@ -304,6 +287,11 @@ class dbTable extends dbObject {
$this->addFieldOpt( $this->current_field, $this->currentElement, $attributes['VALUE'] );
break;
+ case 'DEFDATE':
+ case 'DEFTIMESTAMP':
+ // Add a field option to the table object
+ $this->addFieldOpt( $this->current_field, $this->currentElement );
+ break;
default:
// print_r( array( $tag, $attributes ) );
}
@@ -318,6 +306,12 @@ class dbTable extends dbObject {
switch( $this->currentElement ) {
// Table constraint
case 'CONSTRAINT':
+ if( isset( $this->current_field ) ) {
+ $this->addFieldOpt( $this->current_field, $this->currentElement, $cdata );
+ } else {
+ $this->addTableOpt( $cdata );
+ }
+ break;
// Table option
case 'OPT':
$this->addTableOpt( $cdata );
@@ -341,6 +335,10 @@ class dbTable extends dbObject {
xml_set_object( $parser, $this->parent );
$this->destroy();
break;
+ case 'FIELD':
+ unset($this->current_field);
+ break;
+
}
}
@@ -356,6 +354,19 @@ class dbTable extends dbObject {
return $this->indexes[$name];
}
+ /**
+ * Adds data to a table object
+ *
+ * @param array $attributes Data attributes
+ * @return object dbData object
+ */
+ function &addData( $attributes ) {
+ if( !isset( $this->data ) ) {
+ $this->data =& new dbData( $this, $attributes );
+ }
+ return $this->data;
+ }
+
/**
* Adds a field to a table object
*
@@ -404,7 +415,7 @@ class dbTable extends dbObject {
// Set the field options
if( isset( $opts ) ) {
- $this->fields[$field_id]['OPTS'] = $opts;
+ $this->fields[$field_id]['OPTS'][] = $opts;
}
}
@@ -511,7 +522,7 @@ class dbTable extends dbObject {
if( is_array( $opt ) ) {
$key = key( $opt );
$value = $opt[key( $opt )];
- $fldarray[$field_id][$key] = $value;
+ @$fldarray[$field_id][$key] .= $value;
// Option doesn't have arguments
} else {
$fldarray[$field_id][$opt] = $opt;
@@ -548,6 +559,10 @@ class dbTable extends dbObject {
$sql[] = $index->create( $xmls );
}
+ if( isset( $this->data ) ) {
+ $sql[] = $this->data->create( $xmls );
+ }
+
return $sql;
}
@@ -733,6 +748,192 @@ class dbIndex extends dbObject {
}
}
+/**
+* Creates a data object in ADOdb's datadict format
+*
+* This class stores information about table data.
+*
+* @package axmls
+* @access private
+*/
+class dbData extends dbObject {
+
+ var $data = array();
+
+ var $row;
+
+ /**
+ * Initializes the new dbIndex object.
+ *
+ * @param object $parent Parent object
+ * @param array $attributes Attributes
+ *
+ * @internal
+ */
+ function dbData( &$parent, $attributes = NULL ) {
+ $this->parent =& $parent;
+ }
+
+ /**
+ * XML Callback to process start elements
+ *
+ * Processes XML opening tags.
+ * Elements currently processed are: DROP, CLUSTERED, BITMAP, UNIQUE, FULLTEXT & HASH.
+ *
+ * @access private
+ */
+ function _tag_open( &$parser, $tag, $attributes ) {
+ $this->currentElement = strtoupper( $tag );
+
+ switch( $this->currentElement ) {
+ case 'ROW':
+ $this->row = count( $this->data );
+ $this->data[$this->row] = array();
+ break;
+ case 'F':
+ $this->addField($attributes);
+ default:
+ // print_r( array( $tag, $attributes ) );
+ }
+ }
+
+ /**
+ * XML Callback to process CDATA elements
+ *
+ * Processes XML cdata.
+ *
+ * @access private
+ */
+ function _tag_cdata( &$parser, $cdata ) {
+ switch( $this->currentElement ) {
+ // Index field name
+ case 'F':
+ $this->addData( $cdata );
+ break;
+ default:
+
+ }
+ }
+
+ /**
+ * XML Callback to process end elements
+ *
+ * @access private
+ */
+ function _tag_close( &$parser, $tag ) {
+ $this->currentElement = '';
+
+ switch( strtoupper( $tag ) ) {
+ case 'DATA':
+ xml_set_object( $parser, $this->parent );
+ break;
+ }
+ }
+
+ /**
+ * Adds a field to the index
+ *
+ * @param string $name Field name
+ * @return string Field list
+ */
+ function addField( $attributes ) {
+ if( isset( $attributes['NAME'] ) ) {
+ $name = $attributes['NAME'];
+ } else {
+ $name = count($this->data[$this->row]);
+ }
+
+ // Set the field index so we know where we are
+ $this->current_field = $this->FieldID( $name );
+ }
+
+ /**
+ * Adds options to the index
+ *
+ * @param string $opt Comma-separated list of index options.
+ * @return string Option list
+ */
+ function addData( $cdata ) {
+ if( !isset( $this->data[$this->row] ) ) {
+ $this->data[$this->row] = array();
+ }
+
+ if( !isset( $this->data[$this->row][$this->current_field] ) ) {
+ $this->data[$this->row][$this->current_field] = '';
+ }
+
+ $this->data[$this->row][$this->current_field] .= $cdata;
+ }
+
+ /**
+ * Generates the SQL that will create the index in the database
+ *
+ * @param object $xmls adoSchema object
+ * @return array Array containing index creation SQL
+ */
+ function create( &$xmls ) {
+ $table = $xmls->dict->TableName($this->parent->name);
+ $table_field_count = count($this->parent->fields);
+ $sql = array();
+
+ // eliminate any columns that aren't in the table
+ foreach( $this->data as $row ) {
+ $table_fields = $this->parent->fields;
+ $fields = array();
+
+ foreach( $row as $field_id => $field_data ) {
+ if( !array_key_exists( $field_id, $table_fields ) ) {
+ if( is_numeric( $field_id ) ) {
+ $field_id = reset( array_keys( $table_fields ) );
+ } else {
+ continue;
+ }
+ }
+
+ $name = $table_fields[$field_id]['NAME'];
+
+ switch( $table_fields[$field_id]['TYPE'] ) {
+ case 'C':
+ case 'C2':
+ case 'X':
+ case 'X2':
+ $fields[$name] = $xmls->db->qstr( $field_data );
+ break;
+ case 'I':
+ case 'I1':
+ case 'I2':
+ case 'I4':
+ case 'I8':
+ $fields[$name] = intval($field_data);
+ break;
+ default:
+ $fields[$name] = $field_data;
+ }
+
+ unset($table_fields[$field_id]);
+ }
+
+ // check that at least 1 column is specified
+ if( empty( $fields ) ) {
+ continue;
+ }
+
+ // check that no required columns are missing
+ if( count( $fields ) < $table_field_count ) {
+ foreach( $table_fields as $field ) {
+ if( ( in_array( 'NOTNULL', $field['OPTS'] ) || in_array( 'KEY', $field['OPTS'] ) ) && !in_array( 'AUTOINCREMENT', $field['OPTS'] ) ) {
+ continue(2);
+ }
+ }
+ }
+
+ $sql[] = 'INSERT INTO '. $table .' ('. implode( ',', array_keys( $fields ) ) .') VALUES ('. implode( ',', $fields ) .')';
+ }
+
+ return $sql;
+ }
+}
+
/**
* Creates the SQL to execute a list of provided SQL queries
*
@@ -788,8 +989,6 @@ class dbQuerySet extends dbObject {
case 'NONE':
$this->prefixMethod = 'NONE';
break;
- default:
- $this->prefixMethod = 'AUTO';
}
}
@@ -884,19 +1083,11 @@ class dbQuerySet extends dbObject {
* @return string SQL query string.
*/
function buildQuery( $sql = NULL ) {
- if( !isset( $this->query ) ) {
- return FALSE;
- }
-
- if( empty( $sql ) ) {
+ if( !isset( $this->query ) OR empty( $sql ) ) {
return FALSE;
}
- if( !empty( $this->query ) ) {
- $this->query .= ' ';
- }
-
- $this->query .= trim( $sql );
+ $this->query .= $sql;
return $this->query;
}
@@ -911,8 +1102,7 @@ class dbQuerySet extends dbObject {
return FALSE;
}
- $this->queries[] = $this->query;
- $return = $this->query;
+ $this->queries[] = $return = trim($this->query);
unset( $this->query );
@@ -933,9 +1123,9 @@ class dbQuerySet extends dbObject {
// Process object prefix.
// Evaluate SQL statements to prepend prefix to objects
- $query = $this->prefixQuery( '/^\s*((?is)INSERT\s+(INTO\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query );
- $query = $this->prefixQuery( '/^\s*((?is)UPDATE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query );
- $query = $this->prefixQuery( '/^\s*((?is)DELETE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query );
+ $query = $this->prefixQuery( '/^\s*((?is)INSERT\s+(INTO\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );
+ $query = $this->prefixQuery( '/^\s*((?is)UPDATE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );
+ $query = $this->prefixQuery( '/^\s*((?is)DELETE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );
// SELECT statements aren't working yet
#$data = preg_replace( '/(?ias)(^\s*SELECT\s+.*\s+FROM)\s+(\W\s*,?\s*)+((?i)\s+WHERE.*$)/', "\1 $prefix\2 \3", $data );
@@ -1099,8 +1289,8 @@ class adoSchema {
$this->mgq = get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
- $this->debug = $this->db->debug;
$this->db =& $db;
+ $this->debug = $this->db->debug;
$this->dict = NewDataDictionary( $this->db );
$this->sqlArray = array();
$this->schemaVersion = XMLS_SCHEMA_VERSION;
@@ -1204,10 +1394,11 @@ class adoSchema {
* @see ParseSchemaString()
*
* @param string $file Name of XML schema file.
+ * @param bool $returnSchema Return schema rather than parsing.
* @return array Array of SQL queries, ready to execute
*/
- function ParseSchema( $filename ) {
- return $this->ParseSchemaString( $this->ConvertSchemaFile ( $filename ) );
+ function ParseSchema( $filename, $returnSchema = FALSE ) {
+ return $this->ParseSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );
}
/**
@@ -1217,12 +1408,13 @@ class adoSchema {
* and generate the SQL necessary to create the database described by the schema.
*
* @param string $file Name of XML schema file.
+ * @param bool $returnSchema Return schema rather than parsing.
* @return array Array of SQL queries, ready to execute.
*
* @deprecated Replaced by adoSchema::ParseSchema() and adoSchema::ParseSchemaString()
* @see ParseSchema(), ParseSchemaString()
*/
- function ParseSchemaFile( $filename ) {
+ function ParseSchemaFile( $filename, $returnSchema = FALSE ) {
// Open the file
if( !($fp = fopen( $filename, 'r' )) ) {
// die( 'Unable to open file' );
@@ -1234,6 +1426,13 @@ class adoSchema {
return FALSE;
}
+ if ( $returnSchema )
+ {
+ return $xmlstring;
+ }
+
+ $this->success = 2;
+
$xmlParser = $this->create_parser();
// Process the file
@@ -1260,9 +1459,10 @@ class adoSchema {
* @see ParseSchema()
*
* @param string $xmlstring XML schema string.
+ * @param bool $returnSchema Return schema rather than parsing.
* @return array Array of SQL queries, ready to execute.
*/
- function ParseSchemaString( $xmlstring ) {
+ function ParseSchemaString( $xmlstring, $returnSchema = FALSE ) {
if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) {
return FALSE;
}
@@ -1272,10 +1472,15 @@ class adoSchema {
return FALSE;
}
- $xmlParser = $this->create_parser();
+ if ( $returnSchema )
+ {
+ return $xmlstring;
+ }
$this->success = 2;
+ $xmlParser = $this->create_parser();
+
if( !xml_parse( $xmlParser, $xmlstring, TRUE ) ) {
die( sprintf(
"XML error: %s at line %d",
@@ -1285,9 +1490,46 @@ class adoSchema {
}
xml_parser_free( $xmlParser );
+
return $this->sqlArray;
}
+ /**
+ * Loads an XML schema from a file and converts it to uninstallation SQL.
+ *
+ * Call this method to load the specified schema (see the DTD for the proper format) from
+ * the filesystem and generate the SQL necessary to remove the database described.
+ * @see RemoveSchemaString()
+ *
+ * @param string $file Name of XML schema file.
+ * @param bool $returnSchema Return schema rather than parsing.
+ * @return array Array of SQL queries, ready to execute
+ */
+ function RemoveSchema( $filename, $returnSchema = FALSE ) {
+ return $this->RemoveSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );
+ }
+
+ /**
+ * Converts an XML schema string to uninstallation SQL.
+ *
+ * Call this method to parse a string containing an XML schema (see the DTD for the proper format)
+ * and generate the SQL necessary to uninstall the database described by the schema.
+ * @see RemoveSchema()
+ *
+ * @param string $schema XML schema string.
+ * @param bool $returnSchema Return schema rather than parsing.
+ * @return array Array of SQL queries, ready to execute.
+ */
+ function RemoveSchemaString( $schema, $returnSchema = FALSE ) {
+
+ // grab current version
+ if( !( $version = $this->SchemaStringVersion( $schema ) ) ) {
+ return FALSE;
+ }
+
+ return $this->ParseSchemaString( $this->TransformSchema( $schema, 'remove-' . $version), $returnSchema );
+ }
+
/**
* Applies the current XML schema to the database (post execution).
*
@@ -1448,38 +1690,12 @@ class adoSchema {
if( $version == $newVersion ) {
$result = $schema;
} else {
- // Fail if XSLT extension is not available
- if( ! function_exists( 'xslt_create' ) ) {
- return FALSE;
- }
-
- $xsl_file = dirname( __FILE__ ) . '/xsl/convert-' . $version . '-' . $newVersion . '.xsl';
-
- // look for xsl
- if( !is_readable( $xsl_file ) ) {
- return FALSE;
- }
-
- $arguments = array (
- '/_xml' => $schema,
- '/_xsl' => file_get_contents ($xsl_file)
- );
-
- // create an XSLT processor
- $xh = xslt_create ();
-
- // set error handler
- xslt_set_error_handler ($xh, array (&$this, 'xslt_error_handler'));
-
- // process the schema
- $result = xslt_process ($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
-
- xslt_free ($xh);
+ $result = $this->TransformSchema( $schema, 'convert-' . $version . '-' . $newVersion);
}
- if( is_string ($newFile) AND ( $fp = fopen( $newFile, 'w' ) ) ) {
- fwrite ($fp, $result);
- fclose ($fp);
+ if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) {
+ fwrite( $fp, $result );
+ fclose( $fp );
}
return $result;
@@ -1520,43 +1736,66 @@ class adoSchema {
$result = substr( $result, 3 );
}
} else {
- // Fail if XSLT extension is not available
- if( ! function_exists( 'xslt_create' ) ) {
- return FALSE;
- }
-
- $xsl_file = dirname( __FILE__ ) . '/xsl/convert-' . $version . '-' . $newVersion . '.xsl';
-
- // look for xsl
- if( !is_readable( $xsl_file ) ) {
- return FALSE;
- }
-
- $arguments = array (
- '/_xml' => file_get_contents ($filename),
- '/_xsl' => file_get_contents ($xsl_file)
- );
-
- // create an XSLT processor
- $xh = xslt_create ();
-
- // set error handler
- xslt_set_error_handler ($xh, array (&$this, 'xslt_error_handler'));
-
- // process the schema
- $result = xslt_process ($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
-
- xslt_free ($xh);
+ $result = $this->TransformSchema( $filename, 'convert-' . $version . '-' . $newVersion, 'file' );
}
- if( is_string ($newFile) AND ( $fp = fopen( $newFile, 'w' ) ) ) {
- fwrite ($fp, $result);
- fclose ($fp);
+ if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) {
+ fwrite( $fp, $result );
+ fclose( $fp );
}
return $result;
}
+ function TransformSchema( $schema, $xsl, $schematype='string' )
+ {
+ // Fail if XSLT extension is not available
+ if( ! function_exists( 'xslt_create' ) ) {
+ return FALSE;
+ }
+
+ $xsl_file = dirname( __FILE__ ) . '/xsl/' . $xsl . '.xsl';
+
+ // look for xsl
+ if( !is_readable( $xsl_file ) ) {
+ return FALSE;
+ }
+
+ switch( $schematype )
+ {
+ case 'file':
+ if( !is_readable( $schema ) ) {
+ return FALSE;
+ }
+
+ $schema = file_get_contents( $schema );
+ break;
+ case 'string':
+ default:
+ if( !is_string( $schema ) ) {
+ return FALSE;
+ }
+ }
+
+ $arguments = array (
+ '/_xml' => $schema,
+ '/_xsl' => file_get_contents( $xsl_file )
+ );
+
+ // create an XSLT processor
+ $xh = xslt_create ();
+
+ // set error handler
+ xslt_set_error_handler ($xh, array (&$this, 'xslt_error_handler'));
+
+ // process the schema
+ $result = xslt_process ($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
+
+ xslt_free ($xh);
+
+ return $result;
+ }
+
/**
* Processes XSLT transformation errors
*
@@ -1692,7 +1931,7 @@ class adoSchema {
}
if( $details->primary_key ) {
- $content[] = '';
+ $content[] = '';
} elseif( $details->not_null ) {
$content[] = '';
}
@@ -1743,6 +1982,10 @@ class adoSchema {
$schema .= ' ' . "\n";
while( $row = $rs->FetchRow() ) {
+ foreach( $row as $key => $val ) {
+ $row[$key] = htmlentities($row);
+ }
+
$schema .= ' ' . implode( '', $row ) . ' ' . "\n";
}
@@ -1780,7 +2023,7 @@ class adoSchema {
// prefix too long
case strlen( $prefix ) > XMLS_PREFIX_MAXLEN:
// prefix contains invalid characters
- case !preg_match( '/^[a-z][a-z0-9]+$/i', $prefix ):
+ case !preg_match( '/^[a-z][a-z0-9_]+$/i', $prefix ):
logMsg( 'Invalid prefix: ' . $prefix );
return FALSE;
}
@@ -1931,8 +2174,8 @@ class adoSchema {
*
* @access private
*/
-function logMsg( $msg, $title = NULL ) {
- if( XMLS_DEBUG ) {
+function logMsg( $msg, $title = NULL, $force = FALSE ) {
+ if( XMLS_DEBUG or $force ) {
echo '';
if( isset( $title ) ) {
diff --git a/lib/adodb/adodb.inc.php b/lib/adodb/adodb.inc.php
index 1bcba01267..5c9b9dffe6 100644
--- a/lib/adodb/adodb.inc.php
+++ b/lib/adodb/adodb.inc.php
@@ -224,7 +224,7 @@
var $substr = 'substr'; /// substring operator
var $length = 'length'; /// string length operator
var $random = 'rand()'; /// random function
- var $upperCase = false; /// uppercase function
+ var $upperCase = 'upper'; /// uppercase function
var $fmtDate = "'Y-m-d'"; /// used by DBDate() as the default date format used by the database
var $fmtTimeStamp = "'Y-m-d, h:i:s A'"; /// used by DBTimeStamp as the default timestamp fmt.
var $true = '1'; /// string that represents TRUE for a database
@@ -348,15 +348,17 @@
if ($newline) $msg .= " \n";
- if (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) echo $msg;
+ if (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']) || !$newline) echo $msg;
else echo strip_tags($msg);
+
+
if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); // do not flush if output buffering enabled - useless - thx to Jesse Mullan
}
function Time()
{
- $rs =& $this->Execute("select $this->sysTimeStamp");
+ $rs =& $this->_Execute("select $this->sysTimeStamp");
if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields));
return false;
@@ -617,7 +619,7 @@
For databases that require positioned params, eg $1, $2, $3 for postgresql,
pass in Param(false) before setting the first parameter.
*/
- function Param($name)
+ function Param($name,$type='C')
{
return '?';
}
@@ -754,7 +756,9 @@
$ret =& $fn($this,$sql,$inputarr);
if (isset($ret)) return $ret;
}
- if ($inputarr && is_array($inputarr)) {
+ if ($inputarr) {
+ if (!is_array($inputarr)) $inputarr = array($inputarr);
+
$element0 = reset($inputarr);
# is_object check because oci8 descriptors can be passed in
$array_2d = is_array($element0) && !is_object(reset($element0));
@@ -782,7 +786,7 @@
if ($i+1 != sizeof($sqlarr))
ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql));
- $ret =& $this->_Execute($sql,false);
+ $ret =& $this->_Execute($sql);
if (!$ret) return $ret;
}
} else {
@@ -803,60 +807,23 @@
return $ret;
}
+
function& _Execute($sql,$inputarr=false)
{
if ($this->debug) {
- global $HTTP_SERVER_VARS;
-
- $ss = '';
- if ($inputarr) {
- foreach($inputarr as $kk=>$vv) {
- if (is_string($vv) && strlen($vv)>64) $vv = substr($vv,0,64).'...';
- $ss .= "($kk=>'$vv') ";
- }
- $ss = "[ $ss ]";
- }
- $sqlTxt = str_replace(',',', ',is_array($sql) ?$sql[0] : $sql);
-
- // check if running from browser or command-line
- $inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']);
-
- if ($inBrowser) {
- if ($this->debug === -1)
- ADOConnection::outp( " \n($this->databaseType): ".htmlspecialchars($sqlTxt)." $ss \n \n",false);
- else
- ADOConnection::outp( " \n($this->databaseType): ".htmlspecialchars($sqlTxt)." $ss \n \n",false);
- } else {
- ADOConnection::outp("-----\n($this->databaseType): ".($sqlTxt)." \n-----\n",false);
- }
- $this->_queryID = $this->_query($sql,$inputarr);
- /*
- Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql
- because ErrorNo() calls Execute('SELECT @ERROR'), causing recursion
- */
- if ($this->databaseType == 'mssql') {
- // ErrorNo is a slow function call in mssql, and not reliable in PHP 4.0.6
- if($emsg = $this->ErrorMsg()) {
- if ($err = $this->ErrorNo()) ADOConnection::outp($err.': '.$emsg);
- }
- } else if (!$this->_queryID) {
- ADOConnection::outp($this->ErrorNo() .': '. $this->ErrorMsg());
- }
+ global $ADODB_INCLUDED_LIB;
+ if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
+ $this->_queryID = _adodb_debug_execute($this, $sql,$inputarr);
} else {
- //****************************
- // non-debug version of query
- //****************************
-
- $this->_queryID =@$this->_query($sql,$inputarr);
+ $this->_queryID = @$this->_query($sql,$inputarr);
}
/************************
// OK, query executed
*************************/
- if ($this->_queryID === false) {
- // error handling if query fails
+ if ($this->_queryID === false) { // error handling if query fails
if ($this->debug == 99) adodb_backtrace(true,5);
$fn = $this->raiseErrorFn;
if ($fn) {
@@ -866,12 +833,8 @@
return false;
}
-
- if ($this->_queryID === true) {
- // return simplified empty recordset for inserts/updates/deletes with lower overhead
+ if ($this->_queryID === true) { // return simplified recordset for inserts/updates/deletes with lower overhead
$rs =& new ADORecordSet_empty();
- #if (is_array($sql)) $rs->sql = $sql[0];
- #else $rs->sql = $sql;
return $rs;
}
@@ -885,7 +848,7 @@
if ($rs->_numOfRows <= 0) {
global $ADODB_COUNTRECS;
if ($ADODB_COUNTRECS) {
- if (!$rs->EOF){
+ if (!$rs->EOF) {
$rs = &$this->_rs2rs($rs,-1,-1,!is_array($sql));
$rs->_queryID = $this->_queryID;
} else
@@ -1241,7 +1204,7 @@
if ($rs) {
if (!$rs->EOF) $ret = reset($rs->fields);
$rs->Close();
- }
+ }
$ADODB_COUNTRECS = $crecs;
return $ret;
}
@@ -1481,6 +1444,10 @@
}
return;
}
+
+ global $ADODB_INCLUDED_CSV;
+ if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
+
$f = $this->_gencachename($sql.serialize($inputarr),false);
adodb_write_file($f,''); // is adodb_write_file needed?
if (!@unlink($f)) {
@@ -1631,7 +1598,7 @@
$forcenulls = defined('ADODB_FORCE_NULLS') ? true : false;
}
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
- return _adodb_getupdatesql($this,$rs,$arrFields,$forceUpdate,$magicq);
+ return _adodb_getupdatesql($this,$rs,$arrFields,$forceUpdate,$magicq,$forcenulls);
}
@@ -1650,7 +1617,7 @@
$forcenulls = defined('ADODB_FORCE_NULLS') ? true : false;
}
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
- return _adodb_getinsertsql($this,$rs,$arrFields,$magicq);
+ return _adodb_getinsertsql($this,$rs,$arrFields,$magicq,$forcenulls);
}
@@ -2505,7 +2472,10 @@
* @return an associative array indexed by the first column of the array,
* or false if the data has less than 2 cols.
*/
- function &GetAssoc($force_array = false, $first2cols = false) {
+ function &GetAssoc($force_array = false, $first2cols = false)
+ {
+ global $ADODB_EXTENSION;
+
$cols = $this->_numOfFields;
if ($cols < 2) {
return false;
@@ -2514,32 +2484,64 @@
$results = array();
if (!$first2cols && ($cols > 2 || $force_array)) {
- if ($numIndex) {
- while (!$this->EOF) {
- $results[trim($this->fields[0])] = array_slice($this->fields, 1);
- $this->MoveNext();
+ if ($ADODB_EXTENSION) {
+ if ($numIndex) {
+ while (!$this->EOF) {
+ $results[trim($this->fields[0])] = array_slice($this->fields, 1);
+ adodb_movenext($this);
+ }
+ } else {
+ while (!$this->EOF) {
+ $results[trim(reset($this->fields))] = array_slice($this->fields, 1);
+ adodb_movenext($this);
+ }
}
} else {
- while (!$this->EOF) {
- $results[trim(reset($this->fields))] = array_slice($this->fields, 1);
- $this->MoveNext();
+ if ($numIndex) {
+ while (!$this->EOF) {
+ $results[trim($this->fields[0])] = array_slice($this->fields, 1);
+ $this->MoveNext();
+ }
+ } else {
+ while (!$this->EOF) {
+ $results[trim(reset($this->fields))] = array_slice($this->fields, 1);
+ $this->MoveNext();
+ }
}
}
} else {
- // return scalar values
- if ($numIndex) {
- while (!$this->EOF) {
- // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
- $results[trim(($this->fields[0]))] = $this->fields[1];
- $this->MoveNext();
+ if ($ADODB_EXTENSION) {
+ // return scalar values
+ if ($numIndex) {
+ while (!$this->EOF) {
+ // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
+ $results[trim(($this->fields[0]))] = $this->fields[1];
+ adodb_movenext($this);
+ }
+ } else {
+ while (!$this->EOF) {
+ // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
+ $v1 = trim(reset($this->fields));
+ $v2 = ''.next($this->fields);
+ $results[$v1] = $v2;
+ adodb_movenext($this);
+ }
}
} else {
- while (!$this->EOF) {
- // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
- $v1 = trim(reset($this->fields));
- $v2 = ''.next($this->fields);
- $results[$v1] = $v2;
- $this->MoveNext();
+ if ($numIndex) {
+ while (!$this->EOF) {
+ // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
+ $results[trim(($this->fields[0]))] = $this->fields[1];
+ $this->MoveNext();
+ }
+ } else {
+ while (!$this->EOF) {
+ // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
+ $v1 = trim(reset($this->fields));
+ $v2 = ''.next($this->fields);
+ $results[$v1] = $v2;
+ $this->MoveNext();
+ }
}
}
}
@@ -2728,7 +2730,8 @@
}
*/
return false;
- }
+ }
+
/**
* Random access to a specific row in the recordset. Some databases do not support
@@ -2989,7 +2992,8 @@
*/
function &FetchNextObj()
{
- return $this->FetchNextObject(false);
+ $o = $this->FetchNextObject(false);
+ return $o;
}
@@ -3415,6 +3419,7 @@
if (!$dbType) return false;
$db = strtolower($dbType);
switch ($db) {
+ case 'ifx':
case 'maxsql': $db = 'mysqlt'; break;
case 'postgres':
case 'pgsql': $db = 'postgres7'; break;
@@ -3456,44 +3461,111 @@
if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2);
$errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false;
- if (!empty($ADODB_NEWCONNECTION)) {
- $obj = $ADODB_NEWCONNECTION($db);
- if ($obj) {
- if ($errorfn) $obj->raiseErrorFn = $errorfn;
- return $obj;
+ if (strpos($db,'://')) {
+ $origdsn = $db;
+ $dsna = @parse_url($db);
+ if (!$dsna) {
+ // special handling of oracle, which might not have host
+ $db = str_replace('@/','@adodb-fakehost/',$db);
+ $dsna = parse_url($db);
+ if (!$dsna) return false;
+ $dsna['host'] = '';
}
+ $db = @$dsna['scheme'];
+ 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']) : '';
+ $dsna['path'] = isset($dsna['path']) ? rawurldecode(substr($dsna['path'],1)) : '';
+
+ if (isset($dsna['query'])) {
+ $opt1 = explode('&',$dsna['query']);
+ foreach($opt1 as $k => $v) {
+ $arr = explode('=',$v);
+ $opt[$arr[0]] = isset($arr[1]) ? rawurldecode($arr[1]) : 1;
+ }
+ } else $opt = array();
}
- if (!isset($ADODB_LASTDB)) $ADODB_LASTDB = '';
- if (empty($db)) $db = $ADODB_LASTDB;
-
- if ($db != $ADODB_LASTDB) $db = ADOLoadCode($db);
+ /*
+ * phptype: Database backend used in PHP (mysql, odbc etc.)
+ * dbsyntax: Database used with regards to SQL syntax etc.
+ * protocol: Communication protocol to use (tcp, unix etc.)
+ * hostspec: Host specification (hostname[:port])
+ * database: Database to use on the DBMS server
+ * username: User name for login
+ * password: Password for login
+ */
+ if (!empty($ADODB_NEWCONNECTION)) {
+ $obj = $ADODB_NEWCONNECTION($db);
+
+ } else {
- if (!$db) {
- if ($errorfn) {
- // raise an error
- $ignore = false;
- $errorfn('ADONewConnection', 'ADONewConnection', -998,
- "could not load the database driver for '$db",
- $db,false,$ignore);
- } else
- ADOConnection::outp( "ADONewConnection: Unable to load database driver '$db' ",false);
-
- return false;
+ if (!isset($ADODB_LASTDB)) $ADODB_LASTDB = '';
+ if (empty($db)) $db = $ADODB_LASTDB;
+
+ if ($db != $ADODB_LASTDB) $db = ADOLoadCode($db);
+
+ if (!$db) {
+ if (isset($origdsn)) $db = $origdsn;
+ if ($errorfn) {
+ // raise an error
+ $ignore = false;
+ $errorfn('ADONewConnection', 'ADONewConnection', -998,
+ "could not load the database driver for '$db'",
+ $db,false,$ignore);
+ } else
+ ADOConnection::outp( "ADONewConnection: Unable to load database driver '$db' ",false);
+
+ return false;
+ }
+
+ $cls = 'ADODB_'.$db;
+ if (!class_exists($cls)) {
+ adodb_backtrace();
+ return false;
+ }
+
+ $obj =& new $cls();
}
- $cls = 'ADODB_'.$db;
- if (!class_exists($cls)) {
- adodb_backtrace();
- return false;
+ # constructor should not fail
+ if ($obj) {
+ if ($errorfn) $obj->raiseErrorFn = $errorfn;
+ if (isset($dsna)) {
+
+ foreach($opt as $k => $v) {
+ switch(strtolower($k)) {
+ case 'persist':
+ case 'persistent': $persist = $v; break;
+ case 'debug': $obj->debug = (integer) $v; break;
+ #ibase
+ case 'dialect': $obj->dialect = (integer) $v; break;
+ case 'charset': $obj->charset = $v; break;
+ case 'buffers': $obj->buffers = $v; break;
+ case 'fetchmode': $obj->SetFetchMode($v); break;
+ #ado
+ case 'charpage': $obj->charPage = $v; break;
+ #mysql, mysqli
+ case 'clientflags': $obj->clientFlags = $v; break;
+ #mysqli
+ case 'port': $obj->port = $v; break;
+ case 'socket': $obj->socket = $v; break;
+ }
+ }
+ if (empty($persist))
+ $ok = $obj->Connect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']);
+ else
+ $ok = $obj->PConnect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']);
+
+ if (!$ok) return false;
+ }
}
-
- $obj =& new $cls();
- if ($errorfn) $obj->raiseErrorFn = $errorfn;
-
return $obj;
}
+
+
// $perf == true means called by NewPerfMonitor()
function _adodb_getdriver($provider,$drivername,$perf=false)
{
@@ -3559,56 +3631,6 @@
}
- /**
- * Save a file $filename and its $contents (normally for caching) with file locking
- */
- function adodb_write_file($filename, $contents,$debug=false)
- {
- # http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows
- # So to simulate locking, we assume that rename is an atomic operation.
- # First we delete $filename, then we create a $tempfile write to it and
- # rename to the desired $filename. If the rename works, then we successfully
- # modified the file exclusively.
- # What a stupid need - having to simulate locking.
- # Risks:
- # 1. $tempfile name is not unique -- very very low
- # 2. unlink($filename) fails -- ok, rename will fail
- # 3. adodb reads stale file because unlink fails -- ok, $rs timeout occurs
- # 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated
- if (strncmp(PHP_OS,'WIN',3) === 0) {
- // skip the decimal place
- $mtime = substr(str_replace(' ','_',microtime()),2);
- // getmypid() actually returns 0 on Win98 - never mind!
- $tmpname = $filename.uniqid($mtime).getmypid();
- if (!($fd = fopen($tmpname,'a'))) return false;
- $ok = ftruncate($fd,0);
- if (!fwrite($fd,$contents)) $ok = false;
- fclose($fd);
- chmod($tmpname,0644);
- // the tricky moment
- @unlink($filename);
- if (!@rename($tmpname,$filename)) {
- unlink($tmpname);
- $ok = false;
- }
- if (!$ok) {
- if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed'));
- }
- return $ok;
- }
- if (!($fd = fopen($filename, 'a'))) return false;
- if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) {
- $ok = fwrite( $fd, $contents );
- fclose($fd);
- chmod($filename,0644);
- }else {
- fclose($fd);
- if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename \n");
- $ok = false;
- }
-
- return $ok;
- }
/*
Perform a print_r, with pre tags for better formatting.
@@ -3629,54 +3651,9 @@
*/
function adodb_backtrace($printOrArr=true,$levels=9999)
{
- $s = '';
- if (PHPVERSION() < 4.3) return;
-
- $html = (isset($_SERVER['HTTP_USER_AGENT']));
- $fmt = ($html) ? " %% line %4d, file: %s" : "%% line %4d, file: %s";
-
- $MAXSTRLEN = 64;
-
- $s = ($html) ? '' : '';
-
- if (is_array($printOrArr)) $traceArr = $printOrArr;
- else $traceArr = debug_backtrace();
- array_shift($traceArr);
- $tabs = sizeof($traceArr)-1;
-
- foreach ($traceArr as $arr) {
- $levels -= 1;
- if ($levels < 0) break;
-
- $args = array();
- for ($i=0; $i < $tabs; $i++) $s .= ($html) ? ' ' : "\t";
- $tabs -= 1;
- if ($html) $s .= '';
- if (isset($arr['class'])) $s .= $arr['class'].'.';
- if (isset($arr['args']))
- foreach($arr['args'] as $v) {
- if (is_null($v)) $args[] = 'null';
- else if (is_array($v)) $args[] = 'Array['.sizeof($v).']';
- else if (is_object($v)) $args[] = 'Object:'.get_class($v);
- else if (is_bool($v)) $args[] = $v ? 'true' : 'false';
- else {
- $v = (string) @$v;
- $str = htmlspecialchars(substr($v,0,$MAXSTRLEN));
- if (strlen($v) > $MAXSTRLEN) $str .= '...';
- $args[] = $str;
- }
- }
- $s .= $arr['function'].'('.implode(', ',$args).')';
-
-
- $s .= @sprintf($fmt, $arr['line'],$arr['file'],basename($arr['file']));
-
- $s .= "\n";
- }
- if ($html) $s .= ' ';
- if ($printOrArr) print $s;
-
- return $s;
+ global $ADODB_INCLUDED_LIB;
+ if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
+ return _adodb_backtrace($printOrArr,$levels);
}
} // defined
diff --git a/lib/adodb/datadict/datadict-access.inc.php b/lib/adodb/datadict/datadict-access.inc.php
index 48f02416a8..1ab7b12376 100644
--- a/lib/adodb/datadict/datadict-access.inc.php
+++ b/lib/adodb/datadict/datadict-access.inc.php
@@ -1,7 +1,7 @@
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 $this->fields[] = adodb_date('Y-m-d H:i:s',(float)$f->value);
+ 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) {
@@ -564,7 +568,13 @@ class ADORecordSet_ado extends ADORecordSet {
break;
case 7: // adDate
if (!strlen((string)$f->value)) $this->fields[] = false;
- else $this->fields[] = adodb_date('Y-m-d',(float)$f->value);
+ 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;
diff --git a/lib/adodb/drivers/adodb-ado_access.inc.php b/lib/adodb/drivers/adodb-ado_access.inc.php
index 955fc6d80e..72ff6deebe 100644
--- a/lib/adodb/drivers/adodb-ado_access.inc.php
+++ b/lib/adodb/drivers/adodb-ado_access.inc.php
@@ -1,6 +1,6 @@
GetOne("select 1 as ignore from $tables where $where for update");
}
- function &MetaTables($ttype=false,$showSchema=false)
+ function &MetaTables($ttype=false,$showSchema=false, $qtable="%", $qschema="%")
{
global $ADODB_FETCH_MODE;
$savem = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
- $qid = odbc_tables($this->_connectionID);
+ $qid = odbc_tables($this->_connectionID, "", $qschema, $qtable, "");
$rs = new ADORecordSet_odbc($qid);
@@ -177,6 +176,7 @@ class ADODB_DB2 extends ADODB_odbc {
return $arr2;
}
+
// Format date column in sql string given an input format that understands Y M D
function SQLDate($fmt, $col=false)
{
diff --git a/lib/adodb/drivers/adodb-firebird.inc.php b/lib/adodb/drivers/adodb-firebird.inc.php
index f622263cec..3ac23bdb23 100644
--- a/lib/adodb/drivers/adodb-firebird.inc.php
+++ b/lib/adodb/drivers/adodb-firebird.inc.php
@@ -1,6 +1,6 @@
ibasetrans = IBASE_DEFAULT;
}
+
+ // returns true or false
+ function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$persist=false)
+ {
+ if (!function_exists('ibase_pconnect')) return null;
+ if ($argDatabasename) $argHostname .= ':'.$argDatabasename;
+ $fn = ($persist) ? 'ibase_pconnect':'ibase_connect';
+ $this->_connectionID = $fn($argHostname,$argUsername,$argPassword,
+ $this->charSet,$this->buffers,$this->dialect);
+
+ if ($this->dialect != 1) { // http://www.ibphoenix.com/ibp_60_del_id_ds.html
+ $this->replaceQuote = "''";
+ }
+ if ($this->_connectionID === false) {
+ $this->_handleerror();
+ return false;
+ }
+
+ // PHP5 change.
+ if (function_exists('ibase_timefmt')) {
+ ibase_timefmt($this->ibase_datefmt,IBASE_DATE );
+ if ($this->dialect == 1) ibase_timefmt($this->ibase_datefmt,IBASE_TIMESTAMP );
+ else ibase_timefmt($this->ibase_timestampfmt,IBASE_TIMESTAMP );
+ ibase_timefmt($this->ibase_timefmt,IBASE_TIME );
+
+ } else {
+ ini_set("ibase.timestampformat", $this->ibase_timestampfmt);
+ ini_set("ibase.dateformat", $this->ibase_datefmt);
+ ini_set("ibase.timeformat", $this->ibase_timefmt);
+ }
+ return true;
+ }
+ // returns true or false
+ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,true);
+ }
+
+
function MetaPrimaryKeys($table,$owner_notused=false,$internalKey=false)
{
if ($internalKey) return array('RDB$DB_KEY');
@@ -257,48 +296,6 @@ class ADODB_ibase extends ADOConnection {
return $this->_errorMsg;
}
- // returns true or false
- function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$persist=false)
- {
- if (!function_exists('ibase_pconnect')) return null;
- if ($argDatabasename) $argHostname .= ':'.$argDatabasename;
- $fn = ($persist) ? 'ibase_pconnect':'ibase_connect';
- $this->_connectionID = $fn($argHostname,$argUsername,$argPassword,
- $this->charSet,$this->buffers,$this->dialect);
-
- if ($this->dialect != 1) { // http://www.ibphoenix.com/ibp_60_del_id_ds.html
- $this->replaceQuote = "''";
- }
- if ($this->_connectionID === false) {
- $this->_handleerror();
- return false;
- }
-
- // PHP5 change.
- if (function_exists('ibase_timefmt')) {
- ibase_timefmt($this->ibase_datefmt,IBASE_DATE );
- if ($this->dialect == 1) ibase_timefmt($this->ibase_datefmt,IBASE_TIMESTAMP );
- else ibase_timefmt($this->ibase_timestampfmt,IBASE_TIMESTAMP );
- ibase_timefmt($this->ibase_timefmt,IBASE_TIME );
- } else {
- ini_set("ibase.timestampformat", $this->base_timestampfmt);
- ini_set("ibase.dateformat", $this->ibase_datefmt);
- ini_set("ibase.timeformat", $this->ibase_timefmt);
- }
- //you can use
- /*
- ini_set("ibase.timestampformat", $this->ibase_timestampfmt);
- ini_set("ibase.dateformat", $this->ibase_datefmt);
- ini_set("ibase.timeformat", $this->ibase_timefmt);
- */
- return true;
- }
- // returns true or false
- function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
- {
- return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,true);
- }
-
function Prepare($sql)
{
$stmt = ibase_prepare($this->_connectionID,$sql);
diff --git a/lib/adodb/drivers/adodb-informix72.inc.php b/lib/adodb/drivers/adodb-informix72.inc.php
index 79f0198642..b2e53dec09 100644
--- a/lib/adodb/drivers/adodb-informix72.inc.php
+++ b/lib/adodb/drivers/adodb-informix72.inc.php
@@ -1,6 +1,6 @@
'master'";
var $metaTablesSQL="select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE','dtproperties'))";
@@ -376,14 +375,25 @@ order by constraint_name, referenced_table_name, keyno";
// "Stein-Aksel Basma"
// tested with MSSQL 2000
- function MetaPrimaryKeys($table)
+ function &MetaPrimaryKeys($table)
{
- $sql = "select k.column_name from information_schema.key_column_usage k,
+ global $ADODB_FETCH_MODE;
+
+ $schema = '';
+ $this->_findschema($table,$schema);
+ if (!$schema) $schema = $this->database;
+ if ($schema) $schema = "and k.table_catalog like '$schema%'";
+
+ $sql = "select distinct k.column_name,ordinal_position from information_schema.key_column_usage k,
information_schema.table_constraints tc
where tc.constraint_name = k.constraint_name and tc.constraint_type =
- 'PRIMARY KEY' and k.table_name = '$table'";
+ 'PRIMARY KEY' and k.table_name = '$table' $schema order by ordinal_position ";
+ $savem = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$a = $this->GetCol($sql);
+ $ADODB_FETCH_MODE = $savem;
+
if ($a && sizeof($a)>0) return $a;
return false;
}
@@ -552,6 +562,11 @@ order by constraint_name, referenced_table_name, keyno";
*/
function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
{
+
+ if (strtoupper($blobtype) == 'CLOB') {
+ $sql = "UPDATE $table SET $column='" . $val . "' WHERE $where";
+ return $this->Execute($sql) != false;
+ }
$sql = "UPDATE $table SET $column=0x".bin2hex($val)." WHERE $where";
return $this->Execute($sql) != false;
}
@@ -589,10 +604,16 @@ order by constraint_name, referenced_table_name, keyno";
} else if (is_integer($v)) {
$decl .= "@P$i INT";
$params .= "@P$i=".$v;
- } else {
+ } else if (is_float($v)) {
$decl .= "@P$i FLOAT";
$params .= "@P$i=".$v;
- }
+ } else if (is_bool($v)) {
+ $decl .= "@P$i INT"; # Used INT just in case BIT in not supported on the user's MSSQL version. It will cast appropriately.
+ $params .= "@P$i=".(($v)?'1':'0'); # True == 1 in MSSQL BIT fields and acceptable for storing logical true in an int field
+ } else {
+ $decl .= "@P$i CHAR"; # Used char because a type is required even when the value is to be NULL.
+ $params .= "@P$i=NULL";
+ }
$i += 1;
}
$decl = $this->qstr($decl);
diff --git a/lib/adodb/drivers/adodb-mysql.inc.php b/lib/adodb/drivers/adodb-mysql.inc.php
index 796033477e..e1d9ddc3da 100644
--- a/lib/adodb/drivers/adodb-mysql.inc.php
+++ b/lib/adodb/drivers/adodb-mysql.inc.php
@@ -1,6 +1,6 @@
rsPrefix .= 'ext_';
}
function ServerInfo()
@@ -166,6 +166,11 @@ class ADODB_mysql extends ADOConnection {
return false;
}
+ function BeginTrans()
+ {
+ if ($this->debug) ADOConnection::outp("Transactions not supported in 'mysql' driver. Use 'mysqlt' or 'mysqli' driver");
+ }
+
function _affectedrows()
{
return mysql_affected_rows($this->_connectionID);
@@ -239,18 +244,22 @@ class ADODB_mysql extends ADOConnection {
for ($i=0; $i < $len; $i++) {
$ch = $fmt[$i];
switch($ch) {
+
+ default:
+ if ($ch == '\\') {
+ $i++;
+ $ch = substr($fmt,$i,1);
+ }
+ /** FALL THROUGH */
+ case '-':
+ case '/':
+ $s .= $ch;
+ break;
+
case 'Y':
case 'y':
$s .= '%Y';
break;
- case 'Q':
- case 'q':
- $s .= "'),Quarter($col)";
-
- if ($len > $i+1) $s .= ",DATE_FORMAT($col,'";
- else $s .= ",('";
- $concat = true;
- break;
case 'M':
$s .= '%b';
break;
@@ -263,6 +272,15 @@ class ADODB_mysql extends ADOConnection {
$s .= '%d';
break;
+ case 'Q':
+ case 'q':
+ $s .= "'),Quarter($col)";
+
+ if ($len > $i+1) $s .= ",DATE_FORMAT($col,'";
+ else $s .= ",('";
+ $concat = true;
+ break;
+
case 'H':
$s .= '%H';
break;
@@ -284,14 +302,7 @@ class ADODB_mysql extends ADOConnection {
$s .= '%p';
break;
- default:
-
- if ($ch == '\\') {
- $i++;
- $ch = substr($fmt,$i,1);
- }
- $s .= $ch;
- break;
+
}
}
$s.="')";
@@ -449,7 +460,6 @@ class ADODB_mysql extends ADOConnection {
return $rs;
}
-
// returns queryID or false
function _query($sql,$inputarr)
{
@@ -477,8 +487,6 @@ class ADODB_mysql extends ADOConnection {
else return @mysql_errno($this->_connectionID);
}
-
-
// returns true or false
function _close()
{
@@ -509,6 +517,7 @@ class ADODB_mysql extends ADOConnection {
Class Name: Recordset
--------------------------------------------------------------------------------------*/
+
class ADORecordSet_mysql extends ADORecordSet{
var $databaseType = "mysql";
@@ -587,29 +596,20 @@ class ADORecordSet_mysql extends ADORecordSet{
return @mysql_data_seek($this->_queryID,$row);
}
-
- // 10% speedup to move MoveNext to child class
- function MoveNext()
+ function MoveNext()
{
- //global $ADODB_EXTENSION;if ($ADODB_EXTENSION) return adodb_movenext($this);
-
- if ($this->EOF) return false;
-
- $this->_currentRow++;
- $this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode);
- if (is_array($this->fields)) return true;
-
- $this->EOF = true;
-
- /* -- tested raising an error -- appears pointless
- $conn = $this->connection;
- if ($conn && $conn->raiseErrorFn && ($errno = $conn->ErrorNo())) {
- $fn = $conn->raiseErrorFn;
- $fn($conn->databaseType,'MOVENEXT',$errno,$conn->ErrorMsg().' ('.$this->sql.')',$conn->host,$conn->database);
+ //return adodb_movenext($this);
+ //if (defined('ADODB_EXTENSION')) return adodb_movenext($this);
+ if (@$this->fields =& mysql_fetch_array($this->_queryID,$this->fetchMode)) {
+ $this->_currentRow += 1;
+ return true;
+ }
+ if (!$this->EOF) {
+ $this->_currentRow += 1;
+ $this->EOF = true;
}
- */
return false;
- }
+ }
function _fetch()
{
@@ -676,5 +676,32 @@ class ADORecordSet_mysql extends ADORecordSet{
}
}
+
+class ADORecordSet_ext_mysql extends ADORecordSet_mysql {
+ function ADORecordSet_ext_mysql($queryID,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ switch ($mode)
+ {
+ 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;
+ }
+
+ $this->ADORecordSet($queryID);
+ }
+
+ function MoveNext()
+ {
+ return adodb_movenext($this);
+ }
+}
+
+
}
?>
\ No newline at end of file
diff --git a/lib/adodb/drivers/adodb-mysqli.inc.php b/lib/adodb/drivers/adodb-mysqli.inc.php
index 587083329d..5d68919101 100644
--- a/lib/adodb/drivers/adodb-mysqli.inc.php
+++ b/lib/adodb/drivers/adodb-mysqli.inc.php
@@ -1,6 +1,6 @@
_connectionID = @mysqli_init();
+
+ if (is_null($this->_connectionID)) {
+ // mysqli_init only fails if insufficient memory
+ if ($this->debug)
+ ADOConnection::outp("mysqli_init() failed : " . $this->ErrorMsg());
+ return false;
}
+ // Set connection options
+ // Not implemented now
+ // mysqli_options($this->_connection,,);
+ if (mysqli_real_connect($this->_connectionID,
+ $argHostname,
+ $argUsername,
+ $argPassword,
+ $argDatabasename,
+ $this->port,
+ $this->socket,
+ $this->clientFlags))
+ {
+ if ($argDatabasename) return $this->SelectDB($argDatabasename);
+
+
+ return true;
+ }
+ else {
+ if ($this->debug)
+ ADOConnection::outp("Could't connect : " . $this->ErrorMsg());
+ return false;
+ }
+ }
+
+ // returns true or false
+ // How to force a persistent connection
+ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename, true);
+
}
+ // When is this used? Close old connection first?
+ // In _connect(), check $this->forceNewConnect?
+ function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ $this->forceNewConnect = true;
+ $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
+ }
+
function IfNull( $field, $ifNull )
{
return " IFNULL($field, $ifNull) "; // if MySQL
@@ -329,70 +385,6 @@ class ADODB_mysqli extends ADOConnection {
return "from_unixtime(unix_timestamp($date)+($dayFraction)*24*3600)";
}
- // returns true or false
- // To add: parameter int $port,
- // parameter string $socket
- function _connect($argHostname = NULL,
- $argUsername = NULL,
- $argPassword = NULL,
- $argDatabasename = NULL)
- {
- // @ means: error surpression on
- $this->_connectionID = @mysqli_init();
-
- if (is_null($this->_connectionID))
- {
- // mysqli_init only fails if insufficient memory
- if ($this->debug)
- ADOConnection::outp("mysqli_init() failed : " . $this->ErrorMsg());
- return false;
- }
- // Set connection options
- // Not implemented now
- // mysqli_options($this->_connection,,);
- if (mysqli_real_connect($this->_connectionID,
- $argHostname,
- $argUsername,
- $argPassword,
- $argDatabasename))
- {
- if ($argDatabasename)
- {
- return $this->SelectDB($argDatabasename);
- }
-
- return true;
- }
- else
- {
- if ($this->debug)
- ADOConnection::outp("Could't connect : " . $this->ErrorMsg());
- return false;
- }
- }
-
- // returns true or false
- // How to force a persistent connection
- function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
- {
- // not implemented in mysqli (yet)?
- $this->_connectionID = mysqli_connect($argHostname,
- $argUsername,
- $argPassword,
- $argDatabasename);
- if ($this->_connectionID === false) return false;
- // if ($this->autoRollback) $this->RollbackTrans();
- if ($argDatabasename) return $this->SelectDB($argDatabasename);
- return true;
- }
-
- // When is this used? Close old connection first?
- // In _connect(), check $this->forceNewConnect?
- function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
- {
- $this->forceNewConnect = true;
- $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
- }
function &MetaColumns($table)
{
@@ -539,8 +531,11 @@ class ADODB_mysqli extends ADOConnection {
{
return $sql;
- $stmt = mysqli_prepare($this->_connectionID,$sql);
- if (!$stmt) return false;
+ $stmt = $this->_connectionID->prepare($sql);
+ if (!$stmt) {
+ echo $this->ErrorMsg();
+ return $sql;
+ }
return array($sql,$stmt);
}
@@ -549,18 +544,20 @@ class ADODB_mysqli extends ADOConnection {
function _query($sql, $inputarr)
{
global $ADODB_COUNTRECS;
-
+
if (is_array($sql)) {
$stmt = $sql[1];
+ $a = '';
foreach($inputarr as $k => $v) {
- if (is_string($v)) $a[] = MYSQLI_BIND_STRING;
- else if (is_integer($v)) $a[] = MYSQLI_BIND_INT;
- else $a[] = MYSQLI_BIND_DOUBLE;
-
- $fnarr =& array_merge( array($stmt,$a) , $inputarr);
- $ret = call_user_func_array('mysqli_bind_param',$fnarr);
+ if (is_string($v)) $a .= 's';
+ else if (is_integer($v)) $a .= 'i';
+ else $a .= 'd';
}
- $ret = mysqli_execute($stmt);
+
+ $fnarr =& array_merge( array($stmt,$a) , $inputarr);
+ $ret = call_user_func_array('mysqli_stmt_bind_param',$fnarr);
+
+ $ret = mysqli_stmt_execute($stmt);
return $ret;
}
if (!$mysql_res = mysqli_query($this->_connectionID, $sql, ($ADODB_COUNTRECS) ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT)) {
diff --git a/lib/adodb/drivers/adodb-mysqlt.inc.php b/lib/adodb/drivers/adodb-mysqlt.inc.php
index 87b234fdb6..f7e2bfdd27 100644
--- a/lib/adodb/drivers/adodb-mysqlt.inc.php
+++ b/lib/adodb/drivers/adodb-mysqlt.inc.php
@@ -1,7 +1,7 @@
rsPrefix .= 'ext_';
+ }
+
function BeginTrans()
{
if ($this->transOff) return true;
@@ -59,21 +64,62 @@ class ADODB_mysqlt extends ADODB_mysql {
class ADORecordSet_mysqlt extends ADORecordSet_mysql{
var $databaseType = "mysqlt";
- function ADORecordSet_mysqlt($queryID,$mode=false) {
- return $this->ADORecordSet_mysql($queryID,$mode);
+ function ADORecordSet_mysqlt($queryID,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ switch ($mode)
+ {
+ 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;
+ }
+
+ $this->ADORecordSet($queryID);
}
- function MoveNext()
- {
- if ($this->EOF) return false;
-
- $this->_currentRow++;
- // using & below slows things down by 20%!
- $this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode);
- if ($this->fields) return true;
- $this->EOF = true;
-
+ function MoveNext()
+ {
+ if (@$this->fields =& mysql_fetch_array($this->_queryID,$this->fetchMode)) {
+ $this->_currentRow += 1;
+ return true;
+ }
+ if (!$this->EOF) {
+ $this->_currentRow += 1;
+ $this->EOF = true;
+ }
return false;
- }
+ }
+}
+
+class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
+
+ function ADORecordSet_ext_mysqli($queryID,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ switch ($mode)
+ {
+ 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;
+ }
+
+ $this->ADORecordSet($queryID);
+ }
+
+ function MoveNext()
+ {
+ return adodb_movenext($this);
+ }
}
+
?>
\ No newline at end of file
diff --git a/lib/adodb/drivers/adodb-netezza.inc.php b/lib/adodb/drivers/adodb-netezza.inc.php
index fe74b21e8d..8c2867f404 100644
--- a/lib/adodb/drivers/adodb-netezza.inc.php
+++ b/lib/adodb/drivers/adodb-netezza.inc.php
@@ -1,6 +1,6 @@
_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200;
+ if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_';
}
/* Function &MetaColumns($table) added by smondino@users.sourceforge.net*/
@@ -234,8 +235,6 @@ NATSOFT.DOMAIN =
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,1);
}
-
-
// returns true or false
function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
@@ -576,7 +575,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 = ADODB_oci8::Execute($sql,$arr);
+ $rs = $this->_Execute($sql,$arr);
if ($rez = !empty($rs)) $desc->save($val);
$desc->free();
if ($commit) $this->CommitTrans();
@@ -748,7 +747,7 @@ NATSOFT.DOMAIN =
return $rez;
}
- function Param($name)
+ function Param($name,$type=false)
{
return ':'.$name;
}
@@ -898,6 +897,8 @@ NATSOFT.DOMAIN =
// returns true or false
function _close()
{
+ if (!$this->_connectionID) return;
+
if (!$this->autoCommit) OCIRollback($this->_connectionID);
if (count($this -> _refLOBs) > 0) {
foreach ($this -> _refLOBs as $key => $value) {
@@ -906,6 +907,7 @@ NATSOFT.DOMAIN =
}
}
OCILogoff($this->_connectionID);
+
$this->_stmt = false;
$this->_connectionID = false;
}
@@ -1126,8 +1128,9 @@ class ADORecordset_oci8 extends ADORecordSet {
}
+ /*
// 10% speedup to move MoveNext to child class
- function MoveNext()
+ function _MoveNext()
{
//global $ADODB_EXTENSION;if ($ADODB_EXTENSION) return @adodb_movenext($this);
@@ -1139,7 +1142,22 @@ class ADORecordset_oci8 extends ADORecordSet {
$this->EOF = true;
return false;
- }
+ } */
+
+
+ function MoveNext()
+ {
+ if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
+ $this->_currentRow += 1;
+ return true;
+ }
+ if (!$this->EOF) {
+ $this->_currentRow += 1;
+ $this->EOF = true;
+ }
+ return false;
+ }
+
/* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */
function &GetArrayLimit($nrows,$offset=-1)
@@ -1244,4 +1262,29 @@ class ADORecordset_oci8 extends ADORecordSet {
}
}
}
+
+class ADORecordSet_ext_oci8 extends ADORecordSet_oci8 {
+ function ADORecordSet_ext_oci8($queryID,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ 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;
+ }
+
+ $this->_queryID = $queryID;
+ }
+
+ function MoveNext()
+ {
+ return adodb_movenext($this);
+ }
+}
?>
\ No newline at end of file
diff --git a/lib/adodb/drivers/adodb-oci8po.inc.php b/lib/adodb/drivers/adodb-oci8po.inc.php
index 63a1280166..3d4908c561 100644
--- a/lib/adodb/drivers/adodb-oci8po.inc.php
+++ b/lib/adodb/drivers/adodb-oci8po.inc.php
@@ -1,6 +1,6 @@
ADODB_oci8();
+ $this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200;
+ # oci8po does not support adodb extension: adodb_movenext()
}
function Param($name)
@@ -77,59 +78,72 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
var $databaseType = 'oci8po';
- function ADORecordset_oci8po($queryID,$mode=false)
- {
- $this->ADORecordset_oci8($queryID,$mode);
- }
+ function ADORecordset_oci8po($queryID,$mode=false)
+ {
+ $this->ADORecordset_oci8($queryID,$mode);
+ }
- function Fields($colname)
- {
- if ($this->fetchMode & OCI_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;
- }
+ function Fields($colname)
+ {
+ if ($this->fetchMode & OCI_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)]];
}
-
- // lowercase field names...
- function &_FetchField($fieldOffset = -1)
- {
- $fld = new ADOFieldObject;
- $fieldOffset += 1;
- $fld->name = strtolower(OCIcolumnname($this->_queryID, $fieldOffset));
- $fld->type = OCIcolumntype($this->_queryID, $fieldOffset);
- $fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset);
- if ($fld->type == 'NUMBER') {
- //$p = OCIColumnPrecision($this->_queryID, $fieldOffset);
- $sc = OCIColumnScale($this->_queryID, $fieldOffset);
- if ($sc == 0) $fld->type = 'INT';
- }
- return $fld;
+ return $this->fields[$this->bind[strtoupper($colname)]];
+ }
+
+ // lowercase field names...
+ function &_FetchField($fieldOffset = -1)
+ {
+ $fld = new ADOFieldObject;
+ $fieldOffset += 1;
+ $fld->name = strtolower(OCIcolumnname($this->_queryID, $fieldOffset));
+ $fld->type = OCIcolumntype($this->_queryID, $fieldOffset);
+ $fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset);
+ if ($fld->type == 'NUMBER') {
+ //$p = OCIColumnPrecision($this->_queryID, $fieldOffset);
+ $sc = OCIColumnScale($this->_queryID, $fieldOffset);
+ if ($sc == 0) $fld->type = 'INT';
+ }
+ return $fld;
+ }
+ /*
+ function MoveNext()
+ {
+ if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
+ $this->_currentRow += 1;
+ return true;
+ }
+ if (!$this->EOF) {
+ $this->_currentRow += 1;
+ $this->EOF = true;
}
+ return false;
+ }*/
// 10% speedup to move MoveNext to child class
function MoveNext()
{
-
- if (!$this->EOF) {
+ if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
+ global $ADODB_ANSI_PADDING_OFF;
$this->_currentRow++;
- if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
- global $ADODB_ANSI_PADDING_OFF;
-
- if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();
- if (!empty($ADODB_ANSI_PADDING_OFF)) {
- foreach($this->fields as $k => $v) {
- if (is_string($v)) $this->fields[$k] = rtrim($v);
- }
+
+ if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();
+ if (!empty($ADODB_ANSI_PADDING_OFF)) {
+ foreach($this->fields as $k => $v) {
+ if (is_string($v)) $this->fields[$k] = rtrim($v);
}
- return true;
}
+ return true;
+ }
+ if (!$this->EOF) {
$this->EOF = true;
+ $this->_currentRow++;
}
return false;
}
@@ -190,4 +204,6 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
}
}
+
+
?>
\ No newline at end of file
diff --git a/lib/adodb/drivers/adodb-odbc.inc.php b/lib/adodb/drivers/adodb-odbc.inc.php
index 930f0c201b..50fb08a610 100644
--- a/lib/adodb/drivers/adodb-odbc.inc.php
+++ b/lib/adodb/drivers/adodb-odbc.inc.php
@@ -1,6 +1,6 @@
_connectionID,
+ $rez = @odbc_data_source($this->_connectionID,
$first ? SQL_FETCH_FIRST : SQL_FETCH_NEXT);
$first = false;
if (!is_array($rez)) break;
@@ -232,9 +233,13 @@ class ADODB_odbc extends ADOConnection {
{
global $ADODB_FETCH_MODE;
+ if ($this->uCaseTables) $table = strtoupper($table);
+ $schema = '';
+ $this->_findschema($table,$schema);
+
$savem = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
- $qid = @odbc_primarykeys($this->_connectionID,'','',$table);
+ $qid = @odbc_primarykeys($this->_connectionID,'',$schema,$table);
if (!$qid) {
$ADODB_FETCH_MODE = $savem;
@@ -361,14 +366,14 @@ class ADODB_odbc extends ADOConnection {
{
global $ADODB_FETCH_MODE;
- $table = strtoupper($table);
- $schema = false;
+ if ($this->uCaseTables) $table = strtoupper($table);
+ $schema = '';
$this->_findschema($table,$schema);
$savem = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
- if (false) { // after testing, confirmed that the following does not work becoz of a bug
+ /*if (false) { // after testing, confirmed that the following does not work becoz of a bug
$qid2 = odbc_tables($this->_connectionID);
$rs = new ADORecordSet_odbc($qid2);
$ADODB_FETCH_MODE = $savem;
@@ -387,12 +392,19 @@ class ADODB_odbc extends ADOConnection {
$rs->Close();
$qid = odbc_columns($this->_connectionID,$q,$o,strtoupper($table),'%');
- } else switch ($this->databaseType) {
+ } */
+
+ switch ($this->databaseType) {
case 'access':
case 'vfp':
- case 'db2':
- $qid = odbc_columns($this->_connectionID);
+ $qid = odbc_columns($this->_connectionID);#,'%','',strtoupper($table),'%');
break;
+
+
+ case 'db2':
+ $colname = "%";
+ $qid = odbc_columns($this->_connectionID, "", $schema, $table, $colname);
+ break;
default:
$qid = @odbc_columns($this->_connectionID,'%','%',strtoupper($table),'%');
diff --git a/lib/adodb/drivers/adodb-odbc_mssql.inc.php b/lib/adodb/drivers/adodb-odbc_mssql.inc.php
index 9e01c453e8..abb92fc8bc 100644
--- a/lib/adodb/drivers/adodb-odbc_mssql.inc.php
+++ b/lib/adodb/drivers/adodb-odbc_mssql.inc.php
@@ -1,6 +1,6 @@
_findschema($table,$schema);
+ //if (!$schema) $schema = $this->database;
+ if ($schema) $schema = "and k.table_catalog like '$schema%'";
+
+ $sql = "select distinct k.column_name,ordinal_position from information_schema.key_column_usage k,
information_schema.table_constraints tc
where tc.constraint_name = k.constraint_name and tc.constraint_type =
- 'PRIMARY KEY' and k.table_name = '$table'";
+ 'PRIMARY KEY' and k.table_name = '$table' $schema order by ordinal_position ";
+ $savem = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$a = $this->GetCol($sql);
+ $ADODB_FETCH_MODE = $savem;
+
if ($a && sizeof($a)>0) return $a;
return false;
}
diff --git a/lib/adodb/drivers/adodb-odbc_oracle.inc.php b/lib/adodb/drivers/adodb-odbc_oracle.inc.php
index a3e43e6607..90bfe5a774 100644
--- a/lib/adodb/drivers/adodb-odbc_oracle.inc.php
+++ b/lib/adodb/drivers/adodb-odbc_oracle.inc.php
@@ -1,6 +1,6 @@
_canSelectDb = true;
$this->substr = "substring";
$this->length = 'len';
- $this->upperCase = 'upper';
$this->identitySQL = 'select @@IDENTITY';
$this->metaDatabasesSQL = "select name from master..sysdatabases where name <> 'master'";
break;
@@ -202,7 +201,6 @@ class ADODB_odbtp extends ADOConnection{
$this->replaceQuote = "'+chr(39)+'";
$this->true = '.T.';
$this->false = '.F.';
- $this->upperCase = 'upper';
break;
case ODB_DRIVER_ORACLE:
$this->fmtDate = "'Y-m-d 00:00:00'";
@@ -222,7 +220,6 @@ class ADODB_odbtp extends ADOConnection{
$this->rightOuter = '=*';
$this->hasInsertID = true;
$this->hasTransactions = true;
- $this->upperCase = 'upper';
$this->identitySQL = 'select @@IDENTITY';
break;
default:
@@ -628,6 +625,4 @@ class ADORecordSet_odbtp extends ADORecordSet {
}
}
-?>
-
-
+?>
\ No newline at end of file
diff --git a/lib/adodb/drivers/adodb-odbtp_unicode.inc.php b/lib/adodb/drivers/adodb-odbtp_unicode.inc.php
index af942a352b..78ac4d75f1 100644
--- a/lib/adodb/drivers/adodb-odbtp_unicode.inc.php
+++ b/lib/adodb/drivers/adodb-odbtp_unicode.inc.php
@@ -1,6 +1,6 @@
-
+?>
\ 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 e36216c2b0..3242805ad4 100644
--- a/lib/adodb/drivers/adodb-oracle.inc.php
+++ b/lib/adodb/drivers/adodb-oracle.inc.php
@@ -1,15 +1,15 @@
_findschema($table,$schema);
- $table = strtolower($table);
+ if ($normalize) $table = strtolower($table);
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
@@ -486,7 +486,7 @@ select viewname,'V' from pg_views where viewname like $mask";
}
if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
- else $retarr[($upper) ? strtoupper($fld->name) : $fld->name] = $fld;
+ else $retarr[($normalize) ? strtoupper($fld->name) : $fld->name] = $fld;
$rs->MoveNext();
}
@@ -803,9 +803,9 @@ class ADORecordSet_postgres64 extends ADORecordSet{
// cache types for blob decode check
for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) {
if (pg_fieldtype($qid,$i) == 'bytea') {
- $this->_blobArr[$i] = pg_fieldname($qid,$off);
+ $this->_blobArr[$i] = pg_fieldname($qid,$i);
}
- }
+ }
}
/* Use associative array to get fields array */
@@ -867,7 +867,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{
if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) {
$this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
if (is_array($this->fields) && $this->fields) {
- if ($this->fields && isset($this->_blobArr)) $this->_fixblobs();
+ if (isset($this->_blobArr)) $this->_fixblobs();
return true;
}
}
diff --git a/lib/adodb/drivers/adodb-postgres7.inc.php b/lib/adodb/drivers/adodb-postgres7.inc.php
index 0b9b32c26d..07d0f0887a 100644
--- a/lib/adodb/drivers/adodb-postgres7.inc.php
+++ b/lib/adodb/drivers/adodb-postgres7.inc.php
@@ -1,6 +1,6 @@
0 && $cnt) $cnt += $offset;
$this->Execute("set rowcount $cnt");
- $rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
+ $rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,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 7b1c227207..44538c2108 100644
--- a/lib/adodb/drivers/adodb-vfp.inc.php
+++ b/lib/adodb/drivers/adodb-vfp.inc.php
@@ -1,6 +1,6 @@
100)",'These are sql statements that should be using bind variables'),*/
'index cache cost' => array('COST',
"select value from v\$parameter where name = 'optimizer_index_caching'",
- '% of indexed data blocks expected in the cache.
- Recommended is 20-80. Default is 0. See optimizer_index_caching.'),
-
+ '=WarnIndexCost'),
'random page cost' => array('COST',
"select value from v\$parameter where name = 'optimizer_index_cost_adj'",
- 'Recommended is 10-50 for TP, and 50 for data warehouses. Default is 100. See optimizer_index_cost_adj. '),
+ '=WarnPageCost'),
false
@@ -172,6 +170,23 @@ having count(*) > 100)",'These are sql statements that should be using bind vari
$this->conn =& $conn;
}
+ function WarnPageCost($val)
+ {
+ if ($val == 100) $s = 'Too High. ';
+ else $s = '';
+
+ return $s.'Recommended is 20-50 for TP, and 50 for data warehouses. Default is 100. See optimizer_index_cost_adj. ';
+ }
+
+ function WarnIndexCost($val)
+ {
+ if ($val == 0) $s = 'Too Low. ';
+ else $s = '';
+
+ return $s.'Percentage of indexed data blocks expected in the cache.
+ Recommended is 20 (fast disk array) to 50 (slower hard disks). Default is 0.
+ See optimizer_index_caching.';
+ }
function PGA()
{
diff --git a/lib/adodb/perf/perf-postgres.inc.php b/lib/adodb/perf/perf-postgres.inc.php
index c3d4be5dc6..94785b3a96 100644
--- a/lib/adodb/perf/perf-postgres.inc.php
+++ b/lib/adodb/perf/perf-postgres.inc.php
@@ -1,7 +1,7 @@
PHP ".PHP_VERSION."\n";
try {
-$dbt = 'mysqli';
+$dbt = 'oci8po';
switch($dbt) {
-case 'oci8':
- $db = NewADOConnection("oci8");
+case 'oci8po':
+ $db = NewADOConnection("oci8po");
$db->Connect('','scott','natsoft');
break;
default:
@@ -32,23 +32,26 @@ case 'mysql':
break;
case 'mysqli':
- $db = NewADOConnection("mysqli");
- $db->Connect('localhost','root','','test');
+ $db = NewADOConnection("mysqli://root:@localhost/test");
+ //$db->Connect('localhost','root','','test');
break;
}
$db->debug=1;
-$cnt = $db->GetOne("select count(*) from adoxyz");
-$rs = $db->Execute("select * from adoxyz order by id");
+$cnt = $db->GetOne("select count(*) from adoxyz where ?Prepare("select * from adoxyz where ?ErrorMsg(),"\n";
+$rs = $db->Execute($stmt,array(10,20));
$i = 0;
foreach($rs as $v) {
$i += 1;
- echo "$i: "; adodb_pr($v); adodb_pr($rs->fields);
+ echo "rec $i: "; adodb_pr($v); adodb_pr($rs->fields);
flush();
}
+
if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n");
@@ -60,4 +63,6 @@ $rs = $db->Execute("select bad from badder");
$e = adodb_backtrace($e->gettrace());
}
+$rs = $db->Execute("select distinct id, firstname,lastname from adoxyz order by id");
+echo "Result=\n",$rs;
?>
\ No newline at end of file
diff --git a/lib/adodb/tests/test-xmlschema.php b/lib/adodb/tests/test-xmlschema.php
index aedfb94d33..1134a30f08 100644
--- a/lib/adodb/tests/test-xmlschema.php
+++ b/lib/adodb/tests/test-xmlschema.php
@@ -18,10 +18,10 @@ $schema = new adoSchema( $db );
// uncomment the following line:
#$schema->upgradeSchema();
+print "SQL to build xmlschema.xml:\n";
// Build the SQL array
$sql = $schema->ParseSchema( "xmlschema.xml" );
-print "Here's the SQL to do the build:\n";
print_r( $sql );
print " \n";
@@ -38,10 +38,12 @@ $db2->Connect('localhost','sa','natsoft','northwind') || die("Fail 2");
$db2->Execute("drop table simple_table");
+
+print "SQL to build xmlschema-mssql.xml:\n";
+
$schema = new adoSchema( $db2 );
$sql = $schema->ParseSchema( "xmlschema-mssql.xml" );
-print "Here's the SQL to do the build:\n";
print_r( $sql );
print " \n";
diff --git a/lib/adodb/tests/test.php b/lib/adodb/tests/test.php
index c395b36095..918ba467b0 100644
--- a/lib/adodb/tests/test.php
+++ b/lib/adodb/tests/test.php
@@ -1,6 +1,6 @@
ts4 =".($db->UnixTimeStamp("19700101000101")+8*3600);
print " ts5 =".$db->DBTimeStamp($db->UnixTimeStamp("20040110092123"));
print " ts6 =".$db->UserTimeStamp("20040110092123");
- print " ts6 =".$db->DBTimeStamp("20040110092123");
+ print " ts7 =".$db->DBTimeStamp("20040110092123");
flush();
// mssql too slow in failing bad connection
if (false && $db->databaseType != 'mssql') {
@@ -151,7 +151,7 @@ FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_to
}
error_reporting($e);
flush();
-
+
//$ADODB_COUNTRECS=false;
$rs=$db->Execute('select * from adoxyz order by id');
@@ -410,6 +410,43 @@ GO
$saved = $db->debug;
$db->debug=true;
+
+ /*
+ CREATE TABLE PHOTOS
+ (
+ ID NUMBER(16),
+ PHOTO BLOB,
+ DESCRIPTION VARCHAR2(4000 BYTE),
+ DESCCLOB CLOB
+ );
+
+ INSERT INTO PHOTOS (ID) VALUES(1);
+ */
+ $s = '';
+ for ($i = 0; $i <= 500; $i++) {
+ $s .= '1234567890';
+ }
+
+
+ print "Testing Blob: size=".strlen($s)."";
+ $ok = $db->Updateblob('photos','photo',$s,'id=1');
+ if (!$ok) Err("Blob failed 1");
+ else {
+ $s2= $db->GetOne("select photo from photos where id=1");
+ if ($s !== $s2) Err("updateblob does not match");
+ }
+
+ print "Testing Clob: size=".strlen($s)."";
+ $ok = $db->UpdateClob('photos','descclob',$s,'id=1');
+ if (!$ok) Err("Clob failed 1");
+ else {
+ $s2= $db->GetOne("select descclob from photos where id=1");
+ if ($s !== $s2) Err("updateclob does not match");
+ }
+
+
+ $s = '';
+ $s2 = '';
print "Testing Foreign Keys";
$arr = $db->MetaForeignKeys('emp');
print_r($arr);
@@ -417,30 +454,50 @@ GO
print "Testing Cursor Variables";
/*
-- TEST PACKAGE
-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 data_out(input IN varchar, output OUT varchar);
-END adodb;
+
+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 myproc (p1 IN NUMBER, p2 OUT NUMBER);
+END Adodb;
/
-CREATE OR REPLACE PACKAGE BODY adodb AS
-PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames in varchar) IS
+
+CREATE OR REPLACE PACKAGE BODY Adodb AS
+PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames IN VARCHAR) IS
BEGIN
- OPEN tabcursor FOR SELECT * FROM tab where tname like tablenames;
+ OPEN tabcursor FOR SELECT * FROM TAB WHERE tname LIKE tablenames;
END open_tab;
+
+ PROCEDURE open_tab2 (tabcursor IN OUT TabType,tablenames IN OUT VARCHAR) IS
+ BEGIN
+ 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
+PROCEDURE data_out(input IN VARCHAR, output OUT VARCHAR) IS
BEGIN
output := 'Cinta Hati '||input;
END;
-END adodb;
+
+PROCEDURE myproc (p1 IN NUMBER, p2 OUT NUMBER) AS
+BEGIN
+p2 := p1;
+END;
+END Adodb;
/
+
+
*/
- $rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:RS,'A%'); END;");
+ $rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:zz,'A%'); END;",'zz');
if ($rs && !$rs->EOF) {
- print "Test 1 RowCount: ".$rs->RecordCount()."";
+ $v = $db->GetOne("SELECT count(*) FROM tab where tname like 'A%'");
+ if ($v == $rs->RecordCount()) print "Test 1 RowCount: OK ";
+ else Err("Test 1 RowCount ".$rs->RecordCount().", actual = $v");
} else {
print "Error in using Cursor Variables 1 ";
}
@@ -488,6 +545,7 @@ END adodb;
$db->CompleteTrans();
$rs = $db->Execute('select * from ADOXYZ order by id');
if ($rs->RecordCount() != 3) Err("Bad bulk insert");
+
rs2html($rs);
$db->Execute('delete from ADOXYZ');
@@ -749,8 +807,20 @@ END adodb;
$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 " ";
+
+ //$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");
$rs->MoveNext();
@@ -854,10 +924,10 @@ END adodb;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
if ($db->dataProvider == 'postgres') {
- $sql = "select ".$db->Concat('cast(firstname as varchar)',$db->qstr(' '),'lastname')." as fullname,id from ADOXYZ";
+ $sql = "select ".$db->Concat('cast(firstname as varchar)',$db->qstr(' '),'lastname')." as fullname,id,".$db->sysTimeStamp." as d from ADOXYZ";
$rs = &$db->Execute($sql);
} else {
- $sql = "select distinct ".$db->Concat('firstname',$db->qstr(' '),'lastname')." as fullname,id from ADOXYZ";
+ $sql = "select distinct ".$db->Concat('firstname',$db->qstr(' '),'lastname')." as fullname,id,".$db->sysTimeStamp." as d from ADOXYZ";
$rs = &$db->Execute($sql);
}
if ($rs) {
@@ -904,12 +974,12 @@ END adodb;
//$arr = $db->GetArray("select lastname,firstname from ADOXYZ");
//print_r($arr);
print " ";
- $rs =& $db->Execute("select distinct lastname,firstname from ADOXYZ");
+ $rs =& $db->Execute("select distinct lastname,firstname,created from ADOXYZ");
if ($rs) {
$arr = $rs->GetAssoc();
//print_r($arr);
- if (empty($arr['See']) || trim($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";
}
@@ -1433,7 +1503,7 @@ if (isset($_SERVER['argv'][1])) {
$HTTP_GET_VARS[$_SERVER['argv'][1]] = 1;
}
-if ( @$HTTP_SERVER_VARS['COMPUTERNAME'] == 'TIGRESS') {
+if (@$HTTP_SERVER_VARS['COMPUTERNAME'] == 'TIGRESS') {
CheckWS('mysqlt');
CheckWS('postgres');
CheckWS('oci8po');
@@ -1478,7 +1548,7 @@ if (strpos(PHP_VERSION,'5') === 0) {
This script tests the following databases: Interbase, Oracle, Visual FoxPro, Microsoft Access (ODBC and ADO), MySQL, MSSQL (ODBC, native, ADO).
There is also support for Sybase, PostgreSQL.
-For the latest version of ADODB, visit php.weblogs.com.
+For the latest version of ADODB, visit adodb.sourceforge.net.
Test GetInsertSQL/GetUpdateSQL
Sessions
@@ -1489,8 +1559,9 @@ include('./testdatabases.inc.php');
echo " vers=",ADOConnection::Version();
+
include_once('../adodb-time.inc.php');
-adodb_date_test();
+if (!isset($_GET['nd'])) adodb_date_test();
?>
ADODB Database Library (c) 2000-2004 John Lim. All rights reserved. Released under BSD and LGPL.
|
Walt's new stuff failed: $insertS
$sql = "
SELECT *
-FROM ADOXYZ WHERE lastname=".$conn->qstr($record['lastname']);
+FROM ADOXYZ WHERE lastname=".$conn->qstr($record['lastname']). " ORDER BY 1";
// Select a record to update
$rs = $conn->Execute($sql); // Execute the query and get the existing record to update
diff --git a/lib/adodb/tests/test5.php b/lib/adodb/tests/test5.php
index 64fe38e239..1c7a26999d 100644
--- a/lib/adodb/tests/test5.php
+++ b/lib/adodb/tests/test5.php
@@ -1,6 +1,6 @@
Connecting $db->databaseType...";
- if (@$db->Connect("localhost","tester","test","test")) {
+ if ($db->Connect("localhost","tester","test","test")) {
testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname varchar,created date)");
}else
print "ERROR: PostgreSQL requires a database called test on server, user tester, password test.
".$db->ErrorMsg();
@@ -80,7 +80,7 @@ if (!empty($testibase)) {
//$_GET['nolog'] = true;
$db = &ADONewConnection('firebird');
print "Connecting $db->databaseType...
";
- if (@$db->PConnect("localhost:d:\\firebird\\10\\examples\\employee.gdb", "sysdba", "masterkey", ""))
+ if ($db->PConnect("localhost:d:\\firebird\\10\\examples\\employee.gdb", "sysdba", "masterkey", ""))
testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname char(24),price numeric(12,2),created date)");
else print "ERROR: Interbase test requires a database called employee.gdb".'
'.$db->ErrorMsg();
@@ -91,7 +91,7 @@ if (!empty($testsqlite)) {
$db = &ADONewConnection('sqlite');
print "Connecting $db->databaseType...
";
- if (@$db->PConnect("d:\\inetpub\\adodb\\sqlite.db", "", "", ""))
+ if ($db->PConnect("d:\\inetpub\\adodb\\sqlite.db", "", "", ""))
testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
else print "ERROR: SQLite";
@@ -101,10 +101,12 @@ if (!empty($testsqlite)) {
if (!empty($testaccess)) {
$db = &ADONewConnection('access');
print "Connecting $db->databaseType...
";
-
+ $access = 'd:\inetpub\wwwroot\php\NWIND.MDB';
$dsn = "nwind";
- $driver = "Driver={Microsoft Access Driver (*.mdb)};Dbq=d:\inetpub\adodb\northwind.mdb;Uid=Admin;Pwd=;";
- if (@$db->PConnect($dsn, "", "", ""))
+ $dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=$access;Uid=Admin;Pwd=;";
+
+ //$dsn = 'Provider=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=' . $access . ';';
+ if ($db->PConnect($dsn, "", "", ""))
testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
else print "ERROR: Access test requires a Windows ODBC DSN=nwind, Access driver";
@@ -120,7 +122,7 @@ if (!empty($testaccess) && !empty($testado)) { // ADO ACCESS
. 'DATA SOURCE=' . $access . ';';
//. 'USER ID=;PASSWORD=;';
- if (@$db->PConnect($myDSN, "", "", "")) {
+ if ($db->PConnect($myDSN, "", "", "")) {
print "ADO version=".$db->_connectionID->version."
";
testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
} else print "ERROR: Access test requires a Access database $access".'
'.$db->ErrorMsg();
@@ -141,11 +143,14 @@ if (!empty($testvfp)) { // ODBC
// REQUIRES MySQL server at localhost with database 'test'
if (!empty($testmysql)) { // MYSQL
- $db = &ADONewConnection('mysql');
- print "Connecting $db->databaseType...
";
+
if (PHP_VERSION >= 5 || $HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost';
else $server = "mangrove";
- if ($db->PConnect($server, "root", "", "northwind")) {
+ $user = 'root'; $password = ''; $database = 'northwind';
+ $db = &ADONewConnection("mysql://$user:$password@$server/$database?persist");
+ print "Connecting $db->databaseType...
";
+
+ if (true || $db->PConnect($server, "root", "", "northwind")) {
//$db->debug=1;$db->Execute('drop table ADOXYZ');
testdb($db,
"create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)");
@@ -195,12 +200,11 @@ if (!empty($testproxy)){
ADOLoadCode('oci805');
ADOLoadCode("oci8po");
-if (!empty($testoracle)) {
-
- $db = ADONewConnection('oci8po');
+if (!empty($testoracle)) {
+ $dsn = "oci8po://scott:natsoft@panther?persist";
+ $db = ADONewConnection($dsn);
print "Connecting $db->databaseType...
";
- if ($db->Connect('', "scott", "natsoft",''))
- //if ($db->PConnect("", "scott", "tiger", "juris.ecosystem.natsoft.com.my"))
+ if (true || $db->Connect('', "scott", "natsoft",''))
testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)");
else print "ERROR: Oracle test requires an Oracle server setup with scott/natsoft".'
'.$db->ErrorMsg();
@@ -234,10 +238,9 @@ if (!empty($testmssql)) { // MS SQL Server via ODBC
print "Connecting $db->databaseType...
";
- $dsn = "mssql-northwind";
- $dsn = "Driver={SQL Server};Server=localhost;Database=northwind;";
+ $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=localhost;Database=northwind;";
- if (@$db->PConnect($dsn, "adodb", "natsoft", "")) {
+ if ($db->PConnect($dsn, "adodb", "natsoft", "")) {
testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
}
else print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN setup";
@@ -256,7 +259,7 @@ if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC
. "SERVER=tigress;DATABASE=NorthWind;UID=adodb;PWD=natsoft;Trusted_Connection=No" ;
- if (@$db->PConnect($myDSN, "", "", ""))
+ if ($db->PConnect($myDSN, "", "", ""))
testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
else print "ERROR: MSSQL test 2 requires MS SQL 7";
@@ -270,11 +273,8 @@ if (!empty($testmssql)) { // MS SQL Server -- the extension is buggy -- probably
print "Connecting $db->databaseType...
";
$ok = $db->PConnect('tigress','adodb','natsoft','northwind');
- //$rs = $db->Execute("exec sp_ddate");
- //print_r($rs->fields);
- //die();
- if ($ok or @$db->PConnect("mangrove", "sa", "natsoft", "ai")) {
+ if ($ok or $db->PConnect("mangrove", "sa", "natsoft", "ai")) {
AutoDetect_MSSQL_Date_Order($db);
// $db->Execute('drop table adoxyz');
testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
@@ -288,7 +288,6 @@ if (!empty($testmssql) && !empty($testado)) { // ADO ACCESS MSSQL with OLEDB pro
print "Connecting DSN-less OLEDB Provider $db->databaseType...
";
//$db->debug=1;
$myDSN="SERVER=tigress;DATABASE=northwind;Trusted_Connection=yes";
- //$myDSN='SERVER=(local)\NetSDK;DATABASE=northwind;';
if ($db->PConnect($myDSN, "adodb", "natsoft", 'SQLOLEDB'))
testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='mangrove', userid='sa', password='', database='ai'";
diff --git a/lib/adodb/tests/testoci8.php b/lib/adodb/tests/testoci8.php
index df9a38277a..502ff4daf1 100644
--- a/lib/adodb/tests/testoci8.php
+++ b/lib/adodb/tests/testoci8.php
@@ -2,7 +2,7 @@
PConnect('','scott','natsoft');
@@ -44,7 +44,7 @@ if (1) {
}
if (1) {
$db = ADONewConnection('oci8');
- $db->PConnect('','scott','tiger');
+ $db->PConnect('','scott','natsoft');
$db->debug = true;
$db->Execute("delete from emp where ename='John'");
print $db->Affected_Rows().'
';
@@ -53,6 +53,20 @@ if (1) {
// prepare not quite ready for prime time
//$rs = $db->Execute($stmt,array('empno'=>3775,'ename'=>'John'));
if (!$rs) die("Empty RS");
+
+ $db->setfetchmode(ADODB_FETCH_NUM);
+
+ $vv = 'A%';
+ $stmt = $db->PrepareSP("BEGIN adodb.open_tab2(:rs,:tt); END;",true);
+ $db->OutParameter($stmt, $cur, 'rs', -1, OCI_B_CURSOR);
+ $db->OutParameter($stmt, $vv, 'tt');
+ $rs = $db->Execute($stmt);
+ while (!$rs->EOF) {
+ adodb_pr($rs->fields);
+ $rs->MoveNext();
+ }
+ echo " val = $vv";
+
}
if (0) {
diff --git a/lib/adodb/tests/testoci8cursor.php b/lib/adodb/tests/testoci8cursor.php
index c872048862..7196bb60bd 100644
--- a/lib/adodb/tests/testoci8cursor.php
+++ b/lib/adodb/tests/testoci8cursor.php
@@ -1,6 +1,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-] >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+] >
diff --git a/lib/adodb/xsl/remove-0.2.xsl b/lib/adodb/xsl/remove-0.2.xsl
new file mode 100644
index 0000000000..079f161b1c
--- /dev/null
+++ b/lib/adodb/xsl/remove-0.2.xsl
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+ADODB XMLSchema
+http://adodb-xmlschema.sourceforge.net
+
+
+
+Uninstallation Schema
+
+
+
+ 0.2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file