Updated ADOdb to latest version 4.60

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

Some files were not shown because too many files have changed in this diff Show More