imported ADOdb ver. 4.50 which should solve many php5 probs

This commit is contained in:
Ralf Becker 2004-07-10 07:19:40 +00:00
parent d6bc8096ac
commit ec9ef473ce
109 changed files with 2323 additions and 597 deletions

View File

@ -1,15 +1,19 @@
<?php
// security - hide paths
if (!defined('ADODB_DIR')) die();
global $ADODB_INCLUDED_CSV;
$ADODB_INCLUDED_CSV = 1;
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Library for CSV serialization. This is used by the csv/proxy driver and is the
CacheExecute() serialization format.
@ -83,7 +87,7 @@ $ADODB_INCLUDED_CSV = 1;
function &csv2rs($url,&$err,$timeout=0)
{
$err = false;
$fp = @fopen($url,'r');
$fp = @fopen($url,'rb');
if (!$fp) {
$err = $url.' file/URL not found';
return false;
@ -179,14 +183,18 @@ $ADODB_INCLUDED_CSV = 1;
$MAXSIZE = 128000;
$text = fread($fp,$MAXSIZE);
if (strlen($text) === $MAXSIZE) {
if (strlen($text)) {
while ($txt = fread($fp,$MAXSIZE)) {
$text .= $txt;
}
}
fclose($fp);
@$rs = unserialize($text);
$rs = unserialize($text);
if (is_object($rs)) $rs->timeCreated = $ttl;
else {
$err = "Unable to unserialize recordset";
//echo htmlspecialchars($text),' !--END--!<p>';
}
return $rs;
}

View File

@ -1,7 +1,7 @@
<?php
/**
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -16,6 +16,10 @@
/*
Test script for parser
*/
// security - hide paths
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";
@ -257,7 +261,7 @@ class ADODB_DataDict {
$rez = 1;
}
}
return 2;
return $rez;
}
/*

View File

@ -1,6 +1,6 @@
<?php
/**
* @version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
* @version V4.50 6 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.
@ -11,6 +11,7 @@
* Portions (c)1997-2002 The PHP Group.
*/
if (!defined("DB_ERROR")) define("DB_ERROR",-1);
if (!defined("DB_ERROR_SYNTAX")) {
@ -89,6 +90,7 @@ function adodb_error($provider,$dbType,$errno)
function adodb_error_pg($errormsg)
{
if (is_numeric($errormsg)) return (integer) $errormsg;
static $error_regexps = array(
'/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/' => DB_ERROR_NOSUCHTABLE,
'/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => DB_ERROR_ALREADY_EXISTS,
@ -96,7 +98,9 @@ function adodb_error_pg($errormsg)
'/pg_atoi: error in .*: can\'t parse /' => DB_ERROR_INVALID_NUMBER,
'/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => DB_ERROR_NOSUCHFIELD,
'/parser: parse error at or near \"/' => DB_ERROR_SYNTAX,
'/referential integrity violation/' => DB_ERROR_CONSTRAINT
'/referential integrity violation/' => DB_ERROR_CONSTRAINT,
'/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key violates unique constraint/'
=> DB_ERROR_ALREADY_EXISTS
);
reset($error_regexps);
while (list($regexp,$code) = each($error_regexps)) {

View File

@ -1,6 +1,6 @@
<?php
/**
* @version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
* @version V4.50 6 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.
@ -11,6 +11,7 @@
*
*/
// added Claudio Bustos clbustos#entelchile.net
if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);

View File

@ -1,6 +1,6 @@
<?php
/**
* @version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
* @version V4.50 6 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.

View File

@ -1,7 +1,7 @@
<?php
/**
* @version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
* @version V4.50 6 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.
@ -13,6 +13,7 @@
* Exception-handling code using PHP5 exceptions (try-catch-throw).
*/
if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
define('ADODB_ERROR_HANDLER','adodb_throw');

View File

@ -1,14 +1,15 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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 4.
PHP5 Iterator Class:
Declares the ADODB Base Class for PHP5 "ADODB_BASE_RS", and supports iteration with
the ADODB_Iterator class.
$rs = $db->Execute("select * from adoxyz");
foreach($rs as $k => $v) {
@ -19,6 +20,7 @@
Iterator code based on http://cvs.php.net/cvs.php/php-src/ext/spl/examples/cachingiterator.inc?login=2
*/
class ADODB_Iterator implements Iterator {
private $rs;
@ -59,9 +61,16 @@
function __toString()
{
return 'ADODB Iterator';
if (isset($rs->databaseType)) $s = ' for '.$rs->databaseType;
else $s = '';
return 'ADODB Iterator'.$s;
}
function hasMore()
{
return !$this->rs->EOF;
}
}

View File

@ -1,10 +1,13 @@
<?php
// security - hide paths
if (!defined('ADODB_DIR')) die();
global $ADODB_INCLUDED_LIB;
$ADODB_INCLUDED_LIB = 1;
/*
@version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim\@natsoft.com.my). All rights reserved.
@version V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim\@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
@ -137,18 +140,18 @@ function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=f
continue;
}
if ($hasvalue)
$value = ' value="'.htmlspecialchars($zval2).'"';
$value = " value='".htmlspecialchars($zval2)."'";
if (is_array($defstr)) {
if (in_array($selected,$defstr))
$s .= "<option selected$value>".htmlspecialchars($zval).'</option>';
$s .= "<option selected='selected'$value>".htmlspecialchars($zval).'</option>';
else
$s .= "\n<option".$value.'>'.htmlspecialchars($zval).'</option>';
}
else {
if (strcasecmp($selected,$defstr)==0)
$s .= "<option selected$value>".htmlspecialchars($zval).'</option>';
$s .= "<option selected='selected'$value>".htmlspecialchars($zval).'</option>';
else
$s .= "\n<option".$value.'>'.htmlspecialchars($zval).'</option>';
}
@ -206,12 +209,13 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
}
if ($qryRecs !== false) return $qryRecs;
}
//--------------------------------------------
// query rewrite failed - so try slower way...
// strip off unneeded ORDER BY
$rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$sql);
// strip off unneeded ORDER BY if no UNION
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);
if ($rstest) {
$qryRecs = $rstest->RecordCount();
@ -347,7 +351,7 @@ function &_adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputar
return $rsreturn;
}
function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq=false)
function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq=false,$forcenulls=false)
{
if (!$rs) {
printf(ADODB_BAD_RS,'GetUpdateSQL');
@ -391,18 +395,23 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq
$type = $rs->MetaType($field->type);
// is_null requires php 4.0.4
if ((defined('ADODB_FORCE_NULLS') && is_null($arrFields[$upperfname])) ||
if (($forcenulls && is_null($arrFields[$upperfname])) ||
$arrFields[$upperfname] === 'null') {
$setFields .= $field->name . " = null, ";
} else {
if ($type == 'null') {
$type = 'C';
}
if (strpos($upperfname,' ') !== false)
$fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote;
else
$fnameq = $upperfname;
//we do this so each driver can customize the sql for
//DB specific column types.
//Oracle needs BLOB types to be handled with a returning clause
//postgres has special needs as well
$setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname,
$setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq,
$arrFields, $magicq);
}
}
@ -439,9 +448,9 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq
}
}
function adodb_key_exists($key, &$arr)
function adodb_key_exists($key, &$arr,$forcenulls=false)
{
if (!defined('ADODB_FORCE_NULLS')) {
if (!$forcenulls) {
// the following is the old behaviour where null or empty fields are ignored
return (!empty($arr[$key])) || (isset($arr[$key]) && strlen($arr[$key])>0);
}
@ -459,7 +468,7 @@ function adodb_key_exists($key, &$arr)
*
*
*/
function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false)
function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$forcenulls=false)
{
$tableName = '';
$values = '';
@ -499,12 +508,18 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false)
// Set the counter for the number of fields that will be inserted.
$fieldInsertedCount++;
if (strpos($upperfname,' ') !== false)
$fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote;
else
$fnameq = $upperfname;
// Get the name of the fields to insert
$fields .= $field->name . ", ";
$fields .= $fnameq . ", ";
$type = $recordSet->MetaType($field->type);
if ((defined('ADODB_FORCE_NULLS') && is_null($arrFields[$upperfname])) ||
if (($forcenulls && is_null($arrFields[$upperfname])) ||
$arrFields[$upperfname] === 'null') {
$values .= "null, ";
} else {
@ -512,7 +527,7 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false)
//DB specific column types.
//Oracle needs BLOB types to be handled with a returning clause
//postgres has special needs as well
$values .= _adodb_column_sql($zthis, 'I', $type, $upperfname,
$values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq,
$arrFields, $magicq);
}
}
@ -553,7 +568,7 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false)
* @return string
*
*/
function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $arrFields, $magicq)
function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $fnameq, $arrFields, $magicq)
{
$sql = '';
@ -570,16 +585,22 @@ function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $arrFields, $mag
if ($action == 'I') {
$sql = 'empty_blob(), ';
} else {
$sql = $fname. '=empty_blob(), ';
$sql = $fnameq. '=empty_blob(), ';
}
//add the variable to the returning clause array
//so the user can build this later in
//case they want to add more to it
$zthis->_returningArray[$fname] = ':xx'.$fname.'xx';
} else if (empty($arrFields[$fname])){
if ($action == 'I') {
$sql = 'empty_blob(), ';
} else {
$sql = $fnameq. '=empty_blob(), ';
}
} else {
//this is to maintain compatibility
//with older adodb versions.
$sql = _adodb_column_sql($zthis, $action, $type, $fname, $arrFields, $magicq,false);
$sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq,false);
}
break;
@ -593,7 +614,7 @@ function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $arrFields, $mag
if ($action == 'I') {
$sql = ':xx'.$fname.'xx, ';
} else {
$sql = $fname.'=:xx'.$fname.'xx, ';
$sql = $fnameq.'=:xx'.$fname.'xx, ';
}
//add the variable to the returning clause array
//so the user can build this later in
@ -602,19 +623,19 @@ function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $arrFields, $mag
} else {
//this is to maintain compatibility
//with older adodb versions.
$sql = _adodb_column_sql($zthis, $action, $type, $fname, $arrFields, $magicq,false);
$sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq,false);
}
break;
default:
$sql = _adodb_column_sql($zthis, $action, $type, $fname, $arrFields, $magicq,false);
$sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq,false);
break;
}
return $sql;
}
function _adodb_column_sql(&$zthis, $action, $type, $fname, $arrFields, $magicq, $recurse=true)
function _adodb_column_sql(&$zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq, $recurse=true)
{
if ($recurse) {
@ -623,7 +644,7 @@ function _adodb_column_sql(&$zthis, $action, $type, $fname, $arrFields, $magicq,
if ($type == 'L') $type = 'C';
break;
case 'oci8':
return _adodb_column_sql_oci8($zthis, $action, $type, $fname, $arrFields, $magicq);
return _adodb_column_sql_oci8($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq);
}
}
@ -637,7 +658,7 @@ function _adodb_column_sql(&$zthis, $action, $type, $fname, $arrFields, $magicq,
if ($action == 'I') {
$sql = $zthis->qstr($arrFields[$fname],$magicq) . ", ";
} else {
$sql .= $fname . "=" . $zthis->qstr($arrFields[$fname],$magicq) . ", ";
$sql .= $fnameq . "=" . $zthis->qstr($arrFields[$fname],$magicq) . ", ";
}
break;
@ -645,7 +666,7 @@ function _adodb_column_sql(&$zthis, $action, $type, $fname, $arrFields, $magicq,
if ($action == 'I') {
$sql = $zthis->DBDate($arrFields[$fname]) . ", ";
} else {
$sql .= $fname . "=" . $zthis->DBDate($arrFields[$fname]) . ", ";
$sql .= $fnameq . "=" . $zthis->DBDate($arrFields[$fname]) . ", ";
}
break;
@ -653,7 +674,7 @@ function _adodb_column_sql(&$zthis, $action, $type, $fname, $arrFields, $magicq,
if ($action == 'I') {
$sql = $zthis->DBTimeStamp($arrFields[$fname]) . ", ";
} else {
$sql .= $fname . "=" . $zthis->DBTimeStamp($arrFields[$fname]) . ", ";
$sql .= $fnameq . "=" . $zthis->DBTimeStamp($arrFields[$fname]) . ", ";
}
break;
@ -665,7 +686,7 @@ function _adodb_column_sql(&$zthis, $action, $type, $fname, $arrFields, $magicq,
if ($action == 'I') {
$sql .= $val . ", ";
} else {
$sql .= $fname . "=" . $val . ", ";
$sql .= $fnameq . "=" . $val . ", ";
}
break;
}

View File

@ -1,6 +1,7 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.

View File

@ -1,6 +1,6 @@
<?php
/**
* @version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
* @version V4.50 6 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.
@ -28,6 +28,12 @@
nextID
disconnect
getOne
getAssoc
getRow
getCol
getAll
DB_Result
---------
numRows - returns -1 if not supported

View File

@ -1,12 +1,12 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Library for basic performance monitoring and tuning.
@ -20,6 +20,12 @@ if (!defined(ADODB_DIR)) include_once(dirname(__FILE__).'/adodb.inc.php');
include_once(ADODB_DIR.'/tohtml.inc.php');
// avoids localization problems where , is used instead of .
function adodb_round($n,$prec)
{
return number_format($n, $prec, '.', '');
}
/* return microtime value as a float */
function adodb_microtime()
{
@ -89,7 +95,7 @@ global $HTTP_SERVER_VARS;
if (is_array($sql)) $sql = $sql[0];
$arr = array('b'=>trim(substr($sql,0,230)),
'c'=>substr($sql,0,3900), 'd'=>$params,'e'=>$tracer,'f'=>round($time,6));
'c'=>substr($sql,0,3900), 'd'=>$params,'e'=>$tracer,'f'=>adodb_round($time,6));
//var_dump($arr);
$saved = $conn->debug;
$conn->debug = 0;
@ -402,7 +408,7 @@ Committed_AS: 348732 kB
$suffix = ' ... <i>String too long for GET parameter: '.strlen($prefix).'</i>';
$prefix = '';
}
$s .= "<tr><td>".round($rs->fields[0],6)."<td align=right>".$rs->fields[2]."<td><font size=-1>".$prefix.htmlspecialchars($sql).$suffix."</font>".
$s .= "<tr><td>".adodb_round($rs->fields[0],6)."<td align=right>".$rs->fields[2]."<td><font size=-1>".$prefix.htmlspecialchars($sql).$suffix."</font>".
"<td>".$rs->fields[3]."<td>".$rs->fields[4]."</tr>";
$rs->MoveNext();
}
@ -478,7 +484,7 @@ Committed_AS: 348732 kB
$prefix = '';
$suffix = '';
}
$s .= "<tr><td>".round($rs->fields[0],6)."<td align=right>".$rs->fields[2]."<td><font size=-1>".$prefix.htmlspecialchars($sql).$suffix."</font>".
$s .= "<tr><td>".adodb_round($rs->fields[0],6)."<td align=right>".$rs->fields[2]."<td><font size=-1>".$prefix.htmlspecialchars($sql).$suffix."</font>".
"<td>".$rs->fields[3]."<td>".$rs->fields[4]."</tr>";
$rs->MoveNext();
}
@ -628,7 +634,7 @@ Committed_AS: 348732 kB
default:
case 'stats':
echo $this->HealthCheck();
$this->conn->debug=1;
//$this->conn->debug=1;
echo $this->CheckMemory();
break;
case 'poll':

View File

@ -1,7 +1,7 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.

View File

@ -174,6 +174,40 @@ c. Implement daylight savings, which looks awfully complicated, see
CHANGELOG
- 23 June 2004 0.14
Allow you to define your own daylights savings function, adodb_daylight_sv.
If the function is defined (somewhere in an include), then you can correct for daylights savings.
In this example, we apply daylights savings in June or July, adding one hour. This is extremely
unrealistic as it does not take into account time-zone, geographic location, current year.
function adodb_daylight_sv(&$arr, $is_gmt)
{
if ($is_gmt) return;
$m = $arr['mon'];
if ($m == 6 || $m == 7) $arr['hours'] += 1;
}
This is only called by adodb_date() and not by adodb_mktime().
The format of $arr is
Array (
[seconds] => 0
[minutes] => 0
[hours] => 0
[mday] => 1 # day of month, eg 1st day of the month
[mon] => 2 # month (eg. Feb)
[year] => 2102
[yday] => 31 # days in current year
[leap] => # true if leap year
[ndays] => 28 # no of days in current month
)
- 28 Apr 2004 0.13
Fixed adodb_date to properly support $is_gmt. Thx to Dimitar Angelov.
- 20 Mar 2004 0.12
Fixed month calculation error in adodb_date. 2102-June-01 appeared as 2102-May-32.
@ -237,7 +271,7 @@ First implementation.
/*
Version Number
*/
define('ADODB_DATE_VERSION',0.12);
define('ADODB_DATE_VERSION',0.14);
/*
We check for Windows as only +ve ints are accepted as dates on Windows.
@ -273,7 +307,7 @@ function adodb_date_test()
error_reporting(E_ALL);
print "<h4>Testing adodb_date and adodb_mktime. version=".ADODB_DATE_VERSION. "</h4>";
set_time_limit(0);
@set_time_limit(0);
$fail = false;
// This flag disables calling of PHP native functions, so we can properly test the code
@ -551,6 +585,9 @@ function _adodb_getdate($origd=false,$fast=false,$is_gmt=false)
$_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31);
$_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31);
$d366 = $_day_power * 366;
$d365 = $_day_power * 365;
if ($d < 0) {
$origd = $d;
// The valid range of a 32bit signed timestamp is typically from
@ -558,10 +595,9 @@ function _adodb_getdate($origd=false,$fast=false,$is_gmt=false)
for ($a = 1970 ; --$a >= 0;) {
$lastd = $d;
if ($leaf = _adodb_is_leap_year($a)) {
$d += $_day_power * 366;
} else
$d += $_day_power * 365;
if ($leaf = _adodb_is_leap_year($a)) $d += $d366;
else $d += $d365;
if ($d >= 0) {
$year = $a;
break;
@ -589,14 +625,11 @@ function _adodb_getdate($origd=false,$fast=false,$is_gmt=false)
$hour = floor($d/$_hour_power);
} else {
for ($a = 1970 ;; $a++) {
$lastd = $d;
if ($leaf = _adodb_is_leap_year($a)) {
$d -= $_day_power * 366;
} else
$d -= $_day_power * 365;
if ($leaf = _adodb_is_leap_year($a)) $d -= $d366;
else $d -= $d365;
if ($d < 0) {
$year = $a;
break;
@ -660,6 +693,7 @@ function adodb_gmdate($fmt,$d=false)
return adodb_date($fmt,$d,true);
}
// accepts unix timestamp and iso date format in $d
function adodb_date2($fmt, $d=false, $is_gmt=false)
{
if ($d !== false) {
@ -677,21 +711,25 @@ function adodb_date2($fmt, $d=false, $is_gmt=false)
return adodb_date($fmt,$d,$is_gmt);
}
/**
Return formatted date based on timestamp $d
*/
function adodb_date($fmt,$d=false,$is_gmt=false)
{
if ($d === false) return date($fmt);
if ($d === false) return ($is_gmt)? @gmdate($fmt): @date($fmt);
if (!defined('ADODB_TEST_DATES')) {
if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
if (!defined('ADODB_NO_NEGATIVE_TS') || $d >= 0) // if windows, must be +ve integer
return @date($fmt,$d);
return ($is_gmt)? @gmdate($fmt,$d): @date($fmt,$d);
}
}
$_day_power = 86400;
$arr = _adodb_getdate($d,true,$is_gmt);
if (function_exists('adodb_daylight_sv')) adodb_daylight_sv($arr, $is_gmt);
$year = $arr['year'];
$month = $arr['mon'];
$day = $arr['mday'];
@ -822,6 +860,8 @@ function adodb_gmmktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false)
/**
Return a timestamp given a local time. Originally by jackbbs.
Note that $is_dst is not implemented and is ignored.
Not a very fast algorithm - O(n) operation. Could be optimized to O(1).
*/
function adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false,$is_gmt=false)
{
@ -830,7 +870,9 @@ function adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false,$is_gmt=false)
// 1 Jan 1970 could generate negative timestamp, which is illegal
if (!defined('ADODB_NO_NEGATIVE_TS') || ($year >= 1971))
if (1901 < $year && $year < 2038)
return @mktime($hr,$min,$sec,$mon,$day,$year);
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();

View File

@ -2,7 +2,7 @@
/*
* Set tabs to 4 for best viewing.
*
* Latest version is available at http://php.weblogs.com/adodb
* Latest version is available at http://adodb.sourceforge.net
*
* This is the main include file for ADOdb.
* Database specific drivers are stored in the adodb/drivers/adodb-*.inc.php
@ -14,7 +14,7 @@
/**
\mainpage
@version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim\@natsoft.com.my). All rights reserved.
@version V4.50 6 July 2004 (c) 2000-2004 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.
@ -56,7 +56,7 @@
$ADODB_COUNTRECS, // count number of records returned - slows down query
$ADODB_CACHE_DIR, // directory to cache recordsets
$ADODB_EXTENSION, // ADODB extension installed
$ADODB_COMPAT_PATCH, // If $ADODB_COUNTRECS and this is true, $rs->fields is available on EOF
$ADODB_COMPAT_FETCH, // If $ADODB_COUNTRECS and this is true, $rs->fields is available on EOF
$ADODB_FETCH_MODE; // DEFAULT, NUM, ASSOC or BOTH. Default follows native driver default...
//==============================================================================================
@ -91,9 +91,13 @@
if (!defined('TIMESTAMP_FIRST_YEAR')) define('TIMESTAMP_FIRST_YEAR',100);
if (strnatcmp(PHP_VERSION,'4.3.0')>=0) {
// PHP's version scheme makes converting to numbers difficult - workaround
$_adodb_ver = (float) PHP_VERSION;
if ($_adodb_ver >= 5.0) {
define('ADODB_PHPVER',0x5000);
} else if ($_adodb_ver > 4.299999) { # 4.3
define('ADODB_PHPVER',0x4300);
} else if (strnatcmp(PHP_VERSION,'4.2.0')>=0) {
} else if ($_adodb_ver > 4.199999) { # 4.2
define('ADODB_PHPVER',0x4200);
} else if (strnatcmp(PHP_VERSION,'4.0.5')>=0) {
define('ADODB_PHPVER',0x4050);
@ -147,7 +151,7 @@
/**
* ADODB version as a string.
*/
$ADODB_vers = 'V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.';
$ADODB_vers = 'V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.';
/**
* Determines whether recordset->RecordCount() is used.
@ -300,6 +304,13 @@
die('Virtual Class -- cannot instantiate');
}
function Version()
{
global $ADODB_vers;
return (float) substr($ADODB_vers,1);
}
/**
Get server version info...
@ -339,7 +350,7 @@
if (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) echo $msg;
else echo strip_tags($msg);
if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); // dp not flush if output buffering enabled - useless - thx to Jesse Mullan
if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); // do not flush if output buffering enabled - useless - thx to Jesse Mullan
}
@ -370,7 +381,6 @@
if ($argDatabaseName != "") $this->database = $argDatabaseName;
$this->_isPersistentConnection = false;
if ($fn = $this->raiseErrorFn) {
if ($forceNew) {
if ($this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true;
} else {
@ -378,15 +388,10 @@
}
$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);
} else {
if ($forceNew) {
if ($this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true;
} else {
if ($this->_connect($this->host, $this->user, $this->password, $this->database)) return true;
}
}
if ($this->debug) ADOConnection::outp( $this->host.': '.$this->ErrorMsg());
if ($this->debug) ADOConnection::outp( $this->host.': '.$err);
return false;
}
@ -432,16 +437,16 @@
if ($argDatabaseName != "") $this->database = $argDatabaseName;
$this->_isPersistentConnection = true;
if ($fn = $this->raiseErrorFn) {
if ($this->_pconnect($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 (empty($err)) {
$err = "Connection error to server '$argHostname' with user '$argUsername'";
}
if ($fn = $this->raiseErrorFn) {
$fn($this->databaseType,'PCONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this);
} else
if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true;
}
if ($this->debug) ADOConnection::outp( $this->host.': '.$this->ErrorMsg());
if ($this->debug) ADOConnection::outp( $this->host.': '.$err);
return false;
}
@ -679,6 +684,7 @@
$this->transOff = 1;
}
/**
Used together with StartTrans() to end a transaction. Monitors connection
for sql errors, and will commit or rollback as appropriate.
@ -750,7 +756,7 @@
}
if ($inputarr && is_array($inputarr)) {
$element0 = reset($inputarr);
# is_object check is because oci8 descriptors can be passed in
# is_object check because oci8 descriptors can be passed in
$array_2d = is_array($element0) && !is_object(reset($element0));
if (!is_array($sql) && !$this->_bindInputArray) {
@ -786,9 +792,10 @@
$ret =& $this->_Execute($stmt,$arr);
if (!$ret) return $ret;
}
} else
} else {
$ret =& $this->_Execute($sql,$inputarr);
}
}
} else {
$ret =& $this->_Execute($sql,false);
}
@ -863,6 +870,8 @@
if ($this->_queryID === true) {
// return simplified empty recordset for inserts/updates/deletes with lower overhead
$rs =& new ADORecordSet_empty();
#if (is_array($sql)) $rs->sql = $sql[0];
#else $rs->sql = $sql;
return $rs;
}
@ -875,7 +884,6 @@
else $rs->sql = $sql;
if ($rs->_numOfRows <= 0) {
global $ADODB_COUNTRECS;
if ($ADODB_COUNTRECS) {
if (!$rs->EOF){
$rs = &$this->_rs2rs($rs,-1,-1,!is_array($sql));
@ -1169,6 +1177,7 @@
for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) {
$flds[] = $rs->FetchField($i);
}
$arr =& $rs->GetArrayLimit($nrows,$offset);
//print_r($arr);
if ($close) $rs->Close();
@ -1328,6 +1337,11 @@
}
function &CacheGetAll($secs2cache,$sql=false,$inputarr=false)
{
return $this->CacheGetArray($secs2cache,$sql,$inputarr);
}
function &CacheGetArray($secs2cache,$sql=false,$inputarr=false)
{
global $ADODB_COUNTRECS;
@ -1482,18 +1496,29 @@
* - database type (oci8, ibase, ifx, etc)
* - database name
* - userid
* - setFetchMode (adodb 4.23)
*
* We create 256 sub-directories in the cache directory ($ADODB_CACHE_DIR).
* When not in safe mode, we create 256 sub-directories in the cache directory ($ADODB_CACHE_DIR).
* Assuming that we can have 50,000 files per directory with good performance,
* then we can scale to 12.8 million unique cached recordsets. Wow!
*/
function _gencachename($sql,$createdir)
{
global $ADODB_CACHE_DIR;
static $notSafeMode;
$m = md5($sql.$this->databaseType.$this->database.$this->user);
$dir = $ADODB_CACHE_DIR.'/'.substr($m,0,2);
if ($createdir && !file_exists($dir)) {
if ($this->fetchMode === false) {
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
} else {
$mode = $this->fetchMode;
}
$m = md5($sql.$this->databaseType.$this->database.$this->user.$mode);
if (!isset($notSafeMode)) $notSafeMode = !ini_get('safe_mode');
$dir = ($notSafeMode) ? $ADODB_CACHE_DIR.'/'.substr($m,0,2) : $ADODB_CACHE_DIR;
if ($createdir && $notSafeMode && !file_exists($dir)) {
$oldu = umask(0);
if (!mkdir($dir,0771))
if ($this->debug) ADOConnection::outp( "Unable to mkdir $dir for $sql");
@ -1599,9 +1624,12 @@
*
* "Jonathan Younger" <jyounger@unilab.com>
*/
function GetUpdateSQL(&$rs, $arrFields,$forceUpdate=false,$magicq=false)
function GetUpdateSQL(&$rs, $arrFields,$forceUpdate=false,$magicq=false,$forcenulls=null)
{
global $ADODB_INCLUDED_LIB;
if (!isset($forcenulls)) {
$forcenulls = defined('ADODB_FORCE_NULLS') ? true : false;
}
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
return _adodb_getupdatesql($this,$rs,$arrFields,$forceUpdate,$magicq);
}
@ -1615,9 +1643,12 @@
* Note: This function should only be used on a recordset
* that is run against a single table.
*/
function GetInsertSQL(&$rs, $arrFields,$magicq=false)
function GetInsertSQL(&$rs, $arrFields,$magicq=false,$forcenulls=null)
{
global $ADODB_INCLUDED_LIB;
if (!isset($forcenulls)) {
$forcenulls = defined('ADODB_FORCE_NULLS') ? true : false;
}
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
return _adodb_getinsertsql($this,$rs,$arrFields,$magicq);
}
@ -1746,44 +1777,6 @@
}
/**
* $meta contains the desired type, which could be...
* C for character. You will have to define the precision yourself.
* X for teXt. For unlimited character lengths.
* B for Binary
* F for floating point, with no need to define scale and precision
* N for decimal numbers, you will have to define the (scale, precision) yourself
* D for date
* T for timestamp
* L for logical/Boolean
* I for integer
* R for autoincrement counter/integer
* and if you want to use double-byte, add a 2 to the end, like C2 or X2.
*
*
* @return the actual type of the data or false if no such type available
*/
function ActualType($meta)
{
switch($meta) {
case 'C':
case 'X':
return 'VARCHAR';
case 'B':
case 'D':
case 'T':
case 'L':
case 'R':
case 'I':
case 'N':
return false;
}
}
/**
* Close Connection
*/
@ -1978,15 +1971,18 @@
*
* @return array of column names for current table.
*/
function &MetaColumnNames($table)
function &MetaColumnNames($table, $numIndexes=false)
{
$objarr =& $this->MetaColumns($table);
if (!is_array($objarr)) return false;
$arr = array();
foreach($objarr as $v) {
$arr[strtoupper($v->name)] = $v->name;
}
if ($numIndexes) {
$i = 0;
foreach($objarr as $v) $arr[$i++] = $v->name;
} else
foreach($objarr as $v) $arr[strtoupper($v->name)] = $v->name;
return $arr;
}
@ -2058,6 +2054,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;
@ -2097,16 +2094,17 @@
* @return a date formated as user desires
*/
function UserDate($v,$fmt='Y-m-d')
function UserDate($v,$fmt='Y-m-d',$gmt=false)
{
$tt = $this->UnixDate($v);
// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
if (($tt === false || $tt == -1) && $v != false) return $v;
else if ($tt == 0) return $this->emptyDate;
else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR
}
return adodb_date($fmt,$tt);
return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt);
}
@ -2117,21 +2115,21 @@
*
* @return a timestamp formated as user desires
*/
function UserTimeStamp($v,$fmt='Y-m-d H:i:s')
function UserTimeStamp($v,$fmt='Y-m-d H:i:s',$gmt=false)
{
# strlen(14) allows YYYYMMDDHHMMSS format
if (is_numeric($v) && strlen($v)<14) return adodb_date($fmt,$v);
if (is_numeric($v) && strlen($v)<14) return ($gmt) ? adodb_gmdate($fmt,$v) : adodb_date($fmt,$v);
$tt = $this->UnixTimeStamp($v);
// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
if (($tt === false || $tt == -1) && $v != false) return $v;
if ($tt == 0) return $this->emptyTimeStamp;
return adodb_date($fmt,$tt);
return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt);
}
/**
* Quotes a string, without prefixing nor appending quotes.
*/
function addq($s,$magicq=false)
function addq($s,$magic_quotes=false)
{
if (!$magic_quotes) {
@ -2210,9 +2208,9 @@
{
global $ADODB_INCLUDED_LIB;
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
if ($this->pageExecuteCountRows) return _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $secs2cache);
return _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache);
if ($this->pageExecuteCountRows) $rs =& _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $secs2cache);
else $rs =& _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache);
return $rs;
}
@ -2275,6 +2273,7 @@
function Close(){return true;}
function FetchRow() {return false;}
function FieldCount(){ return 0;}
function Init() {}
}
//==============================================================================================
@ -2581,7 +2580,6 @@
else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR
}
return adodb_date($fmt,$tt);
}
@ -2592,11 +2590,12 @@
*/
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) return 0;
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]);
}
@ -2806,7 +2805,7 @@
/**
* Use associative array to get fields array for databases that do not support
* associative arrays. Submitted by Paolo S. Asioli paolo.asioli@libero.it
* associative arrays. Submitted by Paolo S. Asioli paolo.asioli#libero.it
*
* If you don't want uppercase cols, set $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC
* before you execute your SQL statement, and access $rs->fields['col'] directly.
@ -2929,7 +2928,7 @@
* Get the ADOFieldObjects of all columns in an array.
*
*/
function FieldTypesArray()
function& FieldTypesArray()
{
$arr = array();
for ($i=0, $max=$this->_numOfFields; $i < $max; $i++)
@ -3029,10 +3028,10 @@
* additional info (eg. primary_key for mysql).
*
* @return the general type of the data:
* C for character < 200 chars
* X for teXt (>= 200 chars)
* C for character < 250 chars
* X for teXt (>= 250 chars)
* B for Binary
* N for numeric floating point
* N for numeric or floating point
* D for date
* T for timestamp
* L for logical/Boolean
@ -3314,8 +3313,10 @@
/* Use associative array to get fields array */
function Fields($colname)
{
if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname];
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
if (!isset($this->fields[$colname])) $colname = strtolower($colname);
return $this->fields[$colname];
}
if (!$this->bind) {
$this->bind = array();
for ($i=0; $i < $this->_numOfFields; $i++) {
@ -3424,6 +3425,7 @@
$ok = class_exists("ADODB_" . $db);
if ($ok) return $db;
print_r(get_declared_classes());
$file = ADODB_DIR."/drivers/adodb-".$db.".inc.php";
if (!file_exists($file)) ADOConnection::outp("Missing file: $file");
else ADOConnection::outp("Syntax error in file: $file");
@ -3550,7 +3552,7 @@
$dict->connection = &$conn;
$dict->upperName = strtoupper($drivername);
$dict->quote = $conn->nameQuote;
if (is_resource($conn->_connectionID))
if (!empty($conn->_connectionID))
$dict->serverInfo = $conn->ServerInfo();
return $dict;

View File

@ -1,7 +1,7 @@
<?php
/**
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -10,6 +10,9 @@
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB2_access extends ADODB_DataDict {
var $databaseType = 'access';

View File

@ -1,7 +1,7 @@
<?php
/**
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -9,6 +9,8 @@
Set tabs to 4 for best viewing.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB2_db2 extends ADODB_DataDict {

View File

@ -0,0 +1,151 @@
<?php
/**
V4.50 6 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 4 for best viewing.
*/
class ADODB2_firebird15 extends ADODB_DataDict {
var $databaseType = 'firebird15';
var $seqField = false;
var $seqPrefix = 'gen_';
var $blobSize = 40000;
function ActualType($meta)
{
switch($meta) {
case 'C': return 'VARCHAR';
case 'XL':
case 'X': return 'VARCHAR(4000)';
case 'C2': return 'VARCHAR'; // up to 32K
case 'X2': return 'VARCHAR(4000)';
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 'INTEGER';
case 'F': return 'DOUBLE PRECISION';
case 'N': return 'DECIMAL';
default:
return $meta;
}
}
function NameQuote($name = NULL)
{
if (!is_string($name)) {
return FALSE;
}
$name = trim($name);
if ( !is_object($this->connection) ) {
return $name;
}
$quote = $this->connection->nameQuote;
// if name is of the form `name`, quote it
if ( preg_match('/^`(.+)`$/', $name, $matches) ) {
return $quote . $matches[1] . $quote;
}
// if name contains special characters, quote it
if ( !preg_match('/^[' . $this->nameRegex . ']+$/', $name) ) {
return $quote . $name . $quote;
}
return $quote . $name . $quote;
}
function CreateDatabase($dbname, $options=false)
{
$options = $this->_Options($options);
$sql = array();
$sql[] = "DECLARE EXTERNAL FUNCTION LOWER CSTRING(80) RETURNS CSTRING(80) FREE_IT ENTRY_POINT 'IB_UDF_lower' MODULE_NAME 'ib_udf'";
return $sql;
}
function _DropAutoIncrement($t)
{
if (strpos($t,'.') !== false) {
$tarr = explode('.',$t);
return 'DROP GENERATOR '.$tarr[0].'."gen_'.$tarr[1].'"';
}
return 'DROP GENERATOR "GEN_'.$t;
}
function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
{
$suffix = '';
if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
if ($fnotnull) $suffix .= ' NOT NULL';
if ($fautoinc) $this->seqField = $fname;
if ($fconstraint) $suffix .= ' '.$fconstraint;
return $suffix;
}
/*
CREATE or replace TRIGGER jaddress_insert
before insert on jaddress
for each row
begin
IF ( NEW."seqField" IS NULL OR NEW."seqField" = 0 ) THEN
NEW."seqField" = GEN_ID("GEN_tabname", 1);
end;
*/
function _Triggers($tabname,$tableoptions)
{
if (!$this->seqField) return array();
$tab1 = preg_replace( '/"/', '', $tabname );
if ($this->schema) {
$t = strpos($tab1,'.');
if ($t !== false) $tab = substr($tab1,$t+1);
else $tab = $tab1;
$seqField = $this->seqField;
$seqname = $this->schema.'.'.$this->seqPrefix.$tab;
$trigname = $this->schema.'.trig_'.$this->seqPrefix.$tab;
} else {
$seqField = $this->seqField;
$seqname = $this->seqPrefix.$tab1;
$trigname = 'trig_'.$seqname;
}
if (isset($tableoptions['REPLACE']))
{ $sql[] = "DROP GENERATOR \"$seqname\"";
$sql[] = "CREATE GENERATOR \"$seqname\"";
$sql[] = "ALTER TRIGGER \"$trigname\" BEFORE INSERT OR UPDATE AS BEGIN IF ( NEW.$seqField IS NULL OR NEW.$seqField = 0 ) THEN NEW.$seqField = GEN_ID(\"$seqname\", 1); END";
}
else
{ $sql[] = "CREATE GENERATOR \"$seqname\"";
$sql[] = "CREATE TRIGGER \"$trigname\" FOR $tabname BEFORE INSERT OR UPDATE AS BEGIN IF ( NEW.$seqField IS NULL OR NEW.$seqField = 0 ) THEN NEW.$seqField = GEN_ID(\"$seqname\", 1); END";
}
$this->seqField = false;
return $sql;
}
}
?>

View File

@ -1,7 +1,7 @@
<?php
/**
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -10,6 +10,9 @@
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB2_generic extends ADODB_DataDict {
var $databaseType = 'generic';

View File

@ -1,7 +1,7 @@
<?php
/**
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -10,6 +10,9 @@
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB2_ibase extends ADODB_DataDict {
var $databaseType = 'ibase';

View File

@ -1,7 +1,7 @@
<?php
/**
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -10,6 +10,9 @@
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB2_informix extends ADODB_DataDict {
var $databaseType = 'informix';

View File

@ -1,7 +1,7 @@
<?php
/**
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -10,6 +10,9 @@
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB2_mssql extends ADODB_DataDict {
var $databaseType = 'mssql';
@ -225,5 +228,23 @@ CREATE TABLE
return $sql;
}
function _GetSize($ftype, $ty, $fsize, $fprec)
{
switch ($ftype) {
case 'INT':
case 'SMALLINT':
case 'TINYINT':
case 'BIGINT':
return $ftype;
}
if (strlen($fsize) && $ty != 'X' && $ty != 'B' && strpos($ftype,'(') === false) {
$ftype .= "(".$fsize;
if (strlen($fprec)) $ftype .= ",".$fprec;
$ftype .= ')';
}
return $ftype;
}
}
?>

View File

@ -1,7 +1,7 @@
<?php
/**
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -10,6 +10,9 @@
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB2_mysql extends ADODB_DataDict {
var $databaseType = 'mysql';
var $alterCol = ' MODIFY COLUMN';

View File

@ -1,7 +1,7 @@
<?php
/**
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -10,12 +10,16 @@
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB2_oci8 extends ADODB_DataDict {
var $databaseType = 'oci8';
var $seqField = false;
var $seqPrefix = 'SEQ_';
var $dropTable = "DROP TABLE %s CASCADE CONSTRAINTS";
var $trigPrefix = 'TRIG_';
function MetaType($t,$len=-1)
{
@ -129,8 +133,12 @@ class ADODB2_oci8 extends ADODB_DataDict {
function DropColumnSQL($tabname, $flds)
{
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported for Oracle");
return array();
if (!is_array($flds)) $flds = explode(',',$flds);
$sql = array();
$s = "ALTER TABLE $tabname DROP(";
$s .= implode(',',$flds).') CASCADE COSTRAINTS';
$sql[] = $s;
return $sql;
}
function _DropAutoIncrement($t)
@ -178,14 +186,20 @@ end;
if ($t !== false) $tab = substr($tabname,$t+1);
else $tab = $tabname;
$seqname = $this->schema.'.'.$this->seqPrefix.$tab;
$trigname = $this->schema.'.TRIG_'.$this->seqPrefix.$tab;
$trigname = $this->schema.'.'.$this->trigPrefix.$this->seqPrefix.$tab;
} else {
$seqname = $this->seqPrefix.$tabname;
$trigname = "TRIG_$seqname";
$trigname = $this->trigPrefix.$seqname;
}
if (isset($tableoptions['REPLACE'])) $sql[] = "DROP SEQUENCE $seqname";
$sql[] = "CREATE SEQUENCE $seqname";
$sql[] = "CREATE OR REPLACE TRIGGER $trigname BEFORE insert ON $tabname FOR EACH ROW BEGIN select $seqname.nextval into :new.$this->seqField from dual; END;";
$seqCache = '';
if (isset($tableoptions['SEQUENCE_CACHE'])){$seqCache = $tableoptions['SEQUENCE_CACHE'];}
$seqIncr = '';
if (isset($tableoptions['SEQUENCE_INCREMENT'])){$seqIncr = ' INCREMENT BY '.$tableoptions['SEQUENCE_INCREMENT'];}
$seqStart = '';
if (isset($tableoptions['SEQUENCE_START'])){$seqIncr = ' START WITH '.$tableoptions['SEQUENCE_START'];}
$sql[] = "CREATE SEQUENCE $seqname $seqStart $seqIncr $seqCache";
$sql[] = "CREATE OR REPLACE TRIGGER $trigname BEFORE insert ON $tabname FOR EACH ROW WHEN (NEW.$this->seqField IS NULL OR NEW.$this->seqField = 0) BEGIN select $seqname.nextval into :new.$this->seqField from dual; END;";
$this->seqField = false;
return $sql;

View File

@ -1,7 +1,7 @@
<?php
/**
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -10,6 +10,9 @@
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB2_postgres extends ADODB_DataDict {
var $databaseType = 'postgres';

View File

@ -1,7 +1,7 @@
<?php
/**
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -10,6 +10,9 @@
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB2_sybase extends ADODB_DataDict {
var $databaseType = 'sybase';

View File

@ -11,10 +11,14 @@
<body bgcolor="#FFFFFF">
<h2>ADOdb Library for PHP</h2>
<p>V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim#natsoft.com)</p>
<p>V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com)</p>
<p><font size="1">This software is dual licensed using BSD-Style and LGPL. This
means you can use it in compiled proprietary and commercial products.</font></p>
<p>Useful ADOdb links: <a href=http://php.weblogs.com/adodb>Download</a> &nbsp; <a href=http://php.weblogs.com/adodb_manual>Other Docs</a>
<table border=1><tr><td><font color=red>Kindly note that the ADOdb home page has moved to <a href=http://adodb.sourceforge.net/>http://adodb.sourceforge.net/</a> because of the persistent
unreliability of http://php.weblogs.com. <b>Please change your links</b>!</font></td></tr></table>
<p>Useful ADOdb links: <a href=http://adodb.sourceforge.net/#download>Download</a> &nbsp; <a href=http://adodb.sourceforge.net/#docs>Other Docs</a>
<p><a href="#intro"><b>Introduction</b></a><b><br>
<a href="#features">Unique Features</a><br>
@ -181,7 +185,7 @@ visit <a href="http://php.weblogs.com/adodb-cool-applications">http://php.weblog
<p>Feature requests and bug reports can be emailed to <a href="mailto:jlim#natsoft.com.my">jlim#natsoft.com.my</a>
or posted to the ADOdb Help forums at <a href="http://phplens.com/lens/lensforum/topics.php?id=4">http://phplens.com/lens/lensforum/topics.php?id=4</a>.</p>
<h2>Installation Guide<a name="install"></a></h2>
<p>Make sure you are running PHP 4.0.4 or later.
<p>Make sure you are running PHP 4.0.5 or later.
Unpack all the files into a directory accessible by your webserver.</p>
<p>To test, try modifying some of the tutorial examples. Make sure you customize
the connection settings correctly. You can debug using <i>$db->debug = true</i> as shown below:</p>
@ -244,6 +248,7 @@ PHP will share the same connection. This can cause problems if the connections a
different databases. The solution is to always use different userid's for different databases,
or use NConnect().
<a name=connect_ex>
<h3>Examples of Connecting to Databases</h3>
<h4>MySQL and Most Other Database Drivers</h4>
<p>MySQL connections are very straightforward, and the parameters are identical
@ -262,7 +267,7 @@ different databases. The solution is to always use different userid's for differ
<p> b. the classical 4 parameters:</p>
<pre>
$conn-&gt;PConnect('localhost','userid','password','database');
</pre><a name=ldap>
</pre><a name=ldap></a>
<h4>LDAP</h4>
<p>Here is an example of querying a LDAP server. Thanks to Josh Eldridge for the driver and this example:
<pre>
@ -295,10 +300,8 @@ if ($rs)
$rs->MoveNext();
}
$rs = $ldap->Execute( $filter );
print_r( $ldap->GetArray( $filter ) );
$rs = $ldap->Execute( $filter );
print_r( $ldap->GetRow( $filter ) );
$ldap->Close();
@ -311,30 +314,35 @@ You define the database in the $host parameter:
$conn->PConnect('localhost:c:\ibase\employee.gdb','sysdba','masterkey');
</pre>
<h4>SQLite</h4>
Sqlite will create database if it does not exist.
Sqlite will create the database file if it does not exist.
<pre>
$conn = &ADONewConnection('sqlite');
$conn->PConnect('c:\path\to\sqlite.db'); # sqlite will create if does not exist
</pre>
<h4>Oracle</h4>
<p>With Oracle, you can connect in multiple ways.</p>
<h4>Oracle (oci8)</h4>
<p>With oci8, you can connect in multiple ways. Note that oci8 works fine with
newer versions of the Oracle, eg. 9i and 10g.</p>
<p>a. PHP and Oracle reside on the same machine, use default SID.</p>
<pre> $conn-&gt;Connect(false, 'scott', 'tiger');</pre>
<p>b. TNS Name defined, eg. 'myTNS'</p>
<pre> $conn-&gt;PConnect(false, 'scott', 'tiger', 'myTNS');
</pre>
<p>b. TNS Name defined in tnsnames.ora (or ONAMES or HOSTNAMES), eg. 'myTNS'</p>
<pre> $conn-&gt;PConnect(false, 'scott', 'tiger', 'myTNS');</pre>
<p>or</p>
<pre> $conn-&gt;PConnect('myTNS', 'scott', 'tiger');</pre>
<p>c. Host Address and SID</p>
<pre> $conn-&gt;Connect('192.168.0.1', 'scott', 'tiger', 'SID');</pre>
<p>d. Host Address and Service Name</p>
<pre> $conn-&gt;Connect('192.168.0.1', 'scott', 'tiger', 'servicename');</pre>
<p>e. Oracle connection string:
<pre> $cstr = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=$host)(PORT=$port))
(CONNECT_DATA=(SID=$sid)))";
$conn-&gt;Connect($cstr, 'scott', 'tiger');
</pre>
<a name=dsnless></a>
<h4>DSN-less ODBC (access and mssql examples)</h4>
<p>ODBC DSN's can be created in the ODBC control panel, or you can use a DSN-less
connection.To use DSN-less connections with ODBC you need PHP 4.3 or later.
</p>
<p>For Microsoft Access:</a></p>
<p>For Microsoft Access:</p>
<pre>
$db =& ADONewConnection('access');
$dsn = <strong>"Driver=&#123;Microsoft Access Driver (*.mdb)&#125;;Dbq=d:\\northwind.mdb;Uid=Admin;Pwd=;";</strong>
@ -346,6 +354,11 @@ For Microsoft SQL Server:
$dsn = <strong>"Driver=&#123;SQL Server&#125;;Server=localhost;Database=northwind;"</strong>;
$db->Connect($dsn,'userid','password');
</pre>
or if you prefer to use the mssql extension (which is limited to mssql 6.5 functionality):
<pre>
$db =& ADONewConnection('mssql');
$db->Execute("localhost', 'userid', 'password', 'northwind');
</pre>
<b>DSN-less Connections with ADO</b><br>
If you are using versions of PHP earlier than PHP 4.3.0, DSN-less connections
only work with Microsoft's ADO, which is Microsoft's COM based API. An example
@ -385,7 +398,7 @@ using the ADOdb library and Microsoft's ADO:
<p>The fastest way to access the fields is by accessing the array $recordset->fields
directly. Also set the global variables <a href="#adodb_fetch_mode">$ADODB_FETCH_MODE</a>
= ADODB_FETCH_NUM, and (for oci8, ibase/firebird and odbc) <a href="#adodb_countrecs">$ADODB_COUNTRECS</a> = false
before you connect to your database. At the time of writing (Dec 2003).</p>
before you connect to your database.</p>
<p>Consider using bind parameters if your database supports it, as it improves
query plan reuse. Use ADOdb's performance tuning system to identify bottlenecks
quickly. At the time of writing (Dec 2003), this means oci8 and odbc drivers.</p>
@ -470,6 +483,8 @@ catch exceptions on errors as they occur.
<p>Note that reaching EOF is <b>not</b> considered an error nor an exception.
</ul>
<h3><a name="drivers"></a>Databases Supported</h3>
The <i>name</i> below is the value you pass to NewADOConnection($name) to create a connection object for that database.
<p>
<table width="100%" border="1">
<tr valign="top">
<td><b>Name</b></td>
@ -572,19 +587,11 @@ catch exceptions on errors as they occur.
<td><font size="2">Interbase client</font></td>
<td><font size="2">Unix and Windows</font></td>
</tr>
<tr valign="top">
<td><b><font size="2">informix72</font></b></td>
<td><font size="2">C</font></td>
<td><font size="2"> Informix databases before Informix 7.3 that do no support
SELECT FIRST.</font></td>
<td><font size="2">Y/N</font></td>
<td><font size="2">Informix client</font></td>
<td><font size="2">Unix and Windows</font></td>
</tr>
<tr valign="top">
<td><b><font size="2">informix</font></b></td>
<td><font size="2">C</font></td>
<td><font size="2">Generic informix driver.</font></td>
<td><font size="2">Generic informix driver. Use this if you are using Informix 7.3 or later.</font></td>
<td><font size="2">Y/N</font></td>
<td><font size="2">Informix client</font></td>
<td><font size="2">Unix and Windows</font></td>
@ -637,7 +644,7 @@ catch exceptions on errors as they occur.
<td><font size="2">A</font></td>
<td><font size="2">MySQL without transaction support. You can also set $db-&gt;clientFlags
before connecting.</font></td>
<td><font size="2">Y/N</font></td>
<td><font size="2">Y</font></td>
<td><font size="2">MySQL client</font></td>
<td><font size="2">Unix and Windows</font></td>
</tr>
@ -799,11 +806,26 @@ catch exceptions on errors as they occur.
<tr valign="top">
<td height="54"><b><font size="2">sqlite</font></b></td>
<td height="54"><font size="2">B</font></td>
<td height="54"><font size="2">SQLite. Only tested on PHP5.</font></td>
<td height="54"><font size="2">SQLite.</font></td>
<td height="54"><font size="2">Y</font></td>
<td height="54"><font size="2">-</font></td>
<td height="54"> <p><font size="2">Unix and Windows.</font></p></td>
</tr>
<tr valign="top">
<td height="54"><b><font size="2">sqlitepo</font></b></td>
<td height="54"><font size="2">B</font></td>
<td height="54"><font size="2">Portable SQLite driver. This is because assoc mode does not work like other drivers in sqlite.
Namely, when selecting (joining) multiple tables, the table
names are included in the assoc keys in the "sqlite" driver.<p>
In "sqlitepo" driver, the table names are stripped from the returned column names.
When this results in a conflict, the first field get preference.
</font></td>
<td height="54"><font size="2">Y</font></td>
<td height="54"><font size="2">-</font></td>
<td height="54"> <p><font size="2">Unix and Windows.</font></p></td>
</tr>
<tr valign="top">
<td><b><font size="2">sybase</font></b></td>
<td><font size="2">C</font></td>
@ -1096,6 +1118,10 @@ $conn->Execute($updateSQL); # Update the record in the database
$conn->Close();
?>
</pre>
GetInsertSQL/GetUpdateSQL ignore all empty fields (they are not added to the SQL generated).
To explicitly force a field to be set to "null", set the constant define('ADODB_FORCE_NULLS',1) before
you call the functions.
<p>
<h3>Example 8: Implementing Scrolling with Next and Previous<a name="ex8"></a></h3>
<p> The following code creates a very simple recordset pager, where you can scroll
from page to page of a recordset.</p>
@ -1373,12 +1399,38 @@ PEAR::setErrorHandling('PEAR_ERROR_DIE');
$databasename = 'xphplens';
$driver = 'mysql';
$dsn = &quot;$driver://$username:$password@$hostname/$databasename&quot;;</pre>
<pre> $db = DB::Connect($dsn);<br> $rs = $db-&gt;Execute('select firstname,lastname from adoxyz');
<pre> $db = DB::Connect($dsn);<br> $rs = $db-&gt;query('select firstname,lastname from adoxyz');
$cnt = 0;
while ($arr = $rs-&gt;FetchRow()) {
while ($arr = $rs-&gt;fetchRow()) {
print_r($arr); print &quot;&lt;br&gt;&quot;;
}</pre>
<p>This requires PEAR to be installed and in the default include path in php.ini.</p>
<h2><a name="pear"></a>PEAR Compatibility</h2>
We support DSN's (see above), and the following functions:
<pre>
<b> DB_Common</b>
query - returns PEAR_Error on error
limitQuery - return PEAR_Error on error
prepare - does not return PEAR_Error on error
execute - does not return PEAR_Error on error
setFetchMode - supports ASSOC and ORDERED
errorNative
quote
nextID
disconnect
getOne
getAssoc
getRow
getCol
<b> DB_Result</b>
numRows - returns -1 if not supported
numCols
fetchInto - does not support passing of fetchmode
fetchRows - does not support passing of fetchmode
free
</pre>
<h2><a name="caching"></a>Caching of Recordsets</h2>
<p>ADOdb now supports caching of recordsets using the CacheExecute( ), CachePageExecute(
) and CacheSelectLimit( ) functions. There are similar to the non-cache functions,
@ -1407,7 +1459,8 @@ $<font color="#663300">rs</font> = $<font color="#663300">conn</font>->CacheExec
$rs = $conn->CacheExecute('select * from table');
</pre>
<p>Please note that magic_quotes_runtime should be turned off. <a href=http://phplens.com/lens/lensforum/msgs.php?LeNs#LensBM_forummsg>More
info</a>. <font color="#000000">
info</a>, and do not change $ADODB_FETCH_MODE (or SetFetchMode)
as the cached recordset will use the $ADODB_FETCH_MODE set when the query was executed. <font color="#000000">
<h2><a name="pivot"></a>Pivot Tables</h2>
</font> <p><font color="#000000">Since ADOdb 2.30, we support the generation of
SQL to create pivot tables, also known as cross-tabulations. For further explanation
@ -1700,7 +1753,7 @@ in adodb/lang/adodb-$lang.inc.php, where $lang is the supported langauge.
<p>Non-persistent connect to data source or server $<b>host</b>, using userid
$<b>user </b>and password $<b>password</b>. If the server supports multiple
databases, connect to database $<b>database</b>. </p>
<p>Returns true/false depending on connection.</p>
<p>Returns true/false depending on connection success. Since 4.23, null is returned if the extension is not loaded.</p>
<p>ADO Note: If you are using a Microsoft ADO and not OLEDB, you can set the $database
parameter to the OLEDB data provider you are using.</p>
<p>PostgreSQL: An alternative way of connecting to the database is to pass the
@ -1715,8 +1768,10 @@ in adodb/lang/adodb-$lang.inc.php, where $lang is the supported langauge.
<pre> # $oraname in tnsnames.ora/ONAMES/HOSTNAMES
$conn->Connect(false, 'scott', 'tiger', $oraname);
$conn->Connect('server:1521', 'scott', 'tiger', 'ServiceName'); # bypass tnsnames.ora</pre>
<p>There are many examples of connecting to a database at <a href="http://php.weblogs.com/adodb">php.weblogs.com/ADOdb</a>,
<p>There are many examples of connecting to a database.
See <a href=#connect_ex>Connection Examples</a>, <a href="http://php.weblogs.com/adodb">php.weblogs.com/ADOdb</a>,
and in the testdatabases.inc.php file included in the release.</p>
<p><b>PConnect<a name="pconnect"></a>($host,[$user],[$password],[$database])</b></p>
<p>Persistent connect to data source or server $<b>host</b>, using userid $<b>user</b>
and password $<b>password</b>. If the server supports multiple databases,
@ -1724,7 +1779,8 @@ in adodb/lang/adodb-$lang.inc.php, where $lang is the supported langauge.
<p>We now perform a rollback on persistent connection for selected databases since
2.21, as advised in the PHP manual. See change log or source code for which
databases are affected.
<p>Returns true/false depending on connection. See Connect( ) above for more info.</p>
<p>Returns true/false depending on connection. Since 4.23, null is returned if the extension is not loaded.
See Connect( ) above for more info.</p>
<p>Since ADOdb 2.21, we also support autoRollback. If you set:</p>
</font>
<pre> $conn = &amp;NewADOConnection('mysql');
@ -1738,6 +1794,8 @@ in adodb/lang/adodb-$lang.inc.php, where $lang is the supported langauge.
<p>Since ADOdb 3.11, you can force non-persistent
connections even if PConnect is called by defining the constant
ADODB_NEVER_PERSIST before you call PConnect.
<p>
Since 4.23, null is returned if the extension is not loaded.
<p><b>NConnect<a name="nconnect"></a>($host,[$user],[$password],[$database])</b></p>
<p>Always force a new connection. In contrast, PHP sometimes reuses connections
when you use Connect() or PConnect(). Currently works only on mysql (PHP 4.3.0
@ -2042,7 +2100,7 @@ $ret = $db->Replace('atable2',
array('firstname'=>"'Harun'",'lastname'=>"'Al-Rashid'", 'age' => 'null'),
array('lastname','firstname'));
</pre>
<p><b>GetUpdateSQL<a name="getupdatesql"></a>(&$rs, $arrFields, $forceUpdate=false,$magicq=false)</b></p>
<p><b>GetUpdateSQL<a name="getupdatesql"></a>(&$rs, $arrFields, $forceUpdate=false,$magicq=false, $forcenulls=false)</b></p>
<p>Generate SQL to update a table given a recordset $rs, and the modified fields
of the array $arrFields (which must be an associative array holding the column
names and the new values) are compared with the current recordset. If $forceUpdate
@ -2051,15 +2109,19 @@ $ret = $db->Replace('atable2',
to indicate whether magic quotes are enabled (see qstr()). The field names in the array
are case-insensitive.</p>
<p>Since 3.61, define('ADODB_FORCE_NULLS',1) and all PHP nulls will be auto-converted to SQL nulls.
<p><b>GetInsertSQL<a name="getinsertsql"></a>(&$rs, $arrFields,$magicq=false)</b></p>
Since 4.24, we allow you to pass in $forcenulls as a parameter. This overrides the ADODB_FORCE_NULLS
constant.
<p><b>GetInsertSQL<a name="getinsertsql"></a>(&$rs, $arrFields,$magicq=false,$forcenulls=false)</b></p>
<p>Generate SQL to insert into a table given a recordset $rs. Requires the query
to be associative. $magicq is used to indicate whether magic quotes are enabled
(for qstr()). The field names in the array are case-insensitive.</p>
<p>
Since 2.42, you can pass a table name instead of a recordset into
GetInsertSQL (in $rs), and it will generate an insert statement for that table.
<p>Since 3.61, define('ADODB_FORCE_NULLS',1) and all PHP nulls will be auto-converted
to SQL nulls.
Since ADOdb 2.42, you can pass a table name instead of a recordset into
GetInsertSQL (in $rs), and it will generate an insert statement for that table.
Since 4.24, we allow you to pass in $forcenulls as a parameter. This overrides the ADODB_FORCE_NULLS
constant.
<p><b>PageExecute<a name="pageexecute"></a>($sql, $nrows, $page, $inputarr=false)</b>
<p>Used for pagination of recordset. $page is 1-based. See <a href="#ex8">Example
8</a>.</p>
@ -2608,9 +2670,9 @@ printf(&quot;&lt;p&gt;Total queries=%d; total cached=%d&lt;/p&gt;&quot;,$EXECS+$
(required for some databases).
<p>For schema support, pass in the $table parameter, "$schema.$tablename". This is only
supported for selected databases.
<p><b>MetaColumnNames<a name="metacolumnames"></a>($table)</b></p>
<p><b>MetaColumnNames<a name="metacolumnames"></a>($table,$numericIndex=false)</b></p>
<p>Returns an array of column names for $table. Since ADOdb 4.22, this is an associative array, with the
keys in uppercase.
keys in uppercase. Set $numericIndex=true if you want the old behaviour of numeric indexes (since 4.23).
<p>
e.g. array('FIELD1' => 'Field1', 'FIELD2'=>'Field2')
<p>
@ -3082,7 +3144,97 @@ $<font color="#663300">rs</font> = $<font color="#663300">conn</font>->Execute
PHP</a>. </p>
</font>
<h2>Change Log<a name="Changes"></a><a name="changes"></a><a name="changelog"></a></h2>
<p><b>4.?? 2004</b>
<p><a name=4.50></a><b>4.50 6 July 2004</b>
<p>Bumped it to 4.50 to avoid confusion with PHP 4.3.x series.
<p>Added alpha PDO driver. Very buggy, only works with odbc.
<p>Tested mysqli. Set poorAffectedRows = true. Cleaned up movenext() and _fetch().
<p>PageExecute does not work properly with php5 (return val not a variable). Reported Dmytro Sychevsky sych#php.com.ua. Fixed.
<p>MetaTables() for mysql, $showschema parameter was not backward compatible with older versions of adodb. Fixed.
<p>Changed mysql GetOne() to work with mysql 3.23 when using with non-select stmts (e.g. SHOW TABLES).
<p>Changed TRIG_ prefix to a variable in datadict-oci8.inc.php. Thx to Luca.Gioppo#csi.it.
<p>New to adodb-time code. We allow you to define your own daylights savings function,
adodb_daylight_sv for pre-1970 dates. If the function is defined
(somewhere in an include), then you can correct
for daylights savings. See http://phplens.com/phpeverywhere/node/view/16#daylightsavings
for more info.
<p>New sqlitepo driver. This is because assoc mode does not work like other drivers in sqlite.
Namely, when selecting (joining) multiple tables, in assoc mode the table
names are included in the assoc keys in the "sqlite" driver.
In "sqlitepo" driver, the table names are stripped from the returned column names.
When this results in a conflict, the first field get preference.
Contributed by Herman Kuiper herman#ozuzo.net
<p>Added $forcenull parameter to GetInsertSQL/GetUpdateSQL. Idea by Marco Aurelio Silva.
<p>More XHTML changes for GetMenu. By Jeremy Evans.
<p>Fixes some ibase date issues. Thx to stefan bogdan.
<p>Improvements to mysqli driver to support $ADODB_COUNTRECS.
<p>Fixed adodb-csvlib.inc.php problem when reading stream from socket. We need to poll stream continiously.
<p><a name=4.23></a><b>4.23 16 June 2004</b>
<p>
New interbase/firebird fixes thx to Lester Caine.
Driver fixes a problem with getting field names in the result array, and
corrects a couple of data conversions. Also we default to dialect3 for firebird.
Also ibase sysDate property was wrong. Changed to cast as timestamp.
<p>
The datadict driver is set up to give quoted tables and fields as this
was the only way round reserved words being used as field names in
TikiWiki. TikiPro is tidying that up, and I hope to be able to produce a
build of THAT which uses what I consider proper UPPERCASE field and
table names. The conversion of TikiWiki to ADOdb helped in that, but
until the database is completely tidied up in TikiPro ...
<p>Modified _gencachename() to include fetchmode in name hash.
This means you should clear your cache directory after installing this release as the
cache name algorithm has changed.
<p>Now Cache* functions work in safe mode, because we do not create sub-directories in the $ADODB_CACHE_DIR in safe mode. In non-safe mode we still create sub-directories. Done by modifying _gencachename().
<p>Added $gmt parameter (true/false) to UserDate and UserTimeStamp in connection class, to force conversion of input (in local time) to be converted to UTC/GMT.
<p>Mssql datadict did not support INT types properly (no size param allowed).
Added _GetSize() to datadict-mssql.inc.php.
<p>For borland_ibase, BeginTrans(), changed:<br>
<pre> $this->_transactionID = $this->_connectionID;</pre>
to<br>
<pre> $this->_transactionID = ibase_trans($this->ibasetrans, $this->_connectionID);</pre>
<p>Fixed typo in mysqi_field_seek(). Thx to Sh4dow (sh4dow#php.pl).
<p>LogSQL did not work with Firebird/Interbase. Fixed.
<p>Postgres: made errorno() handling more consistent. Thx to Michael Jahn, Michael.Jahn#mailbox.tu-dresden.de.
<p>Added informix patch to better support metatables, metacolumns by "Cecilio Albero" c-albero#eos-i.com
<p>Cyril Malevanov contributed patch to oci8 to support passing of LOB parameters:
<pre>
$text = 'test test test';
$sql = "declare rs clob; begin :rs := lobinout(:sa0); end;";
$stmt = $conn -> PrepareSP($sql);
$conn -> InParameter($stmt,$text,'sa0', -1, OCI_B_CLOB);
$rs = '';
$conn -> OutParameter($stmt,$rs,'rs', -1, OCI_B_CLOB);
$conn -> Execute($stmt);
echo "return = ".$rs."&lt;br>";
</pre>
As he says, the LOBs limitations are:
<pre>
- use OCINewDescriptor before binding
- if Param is IN, uses save() before each execute. This is done automatically for you.
- if Param is OUT, uses load() after each execute. This is done automatically for you.
- when we bind $var as LOB, we create new descriptor and return it as a
Bind Result, so if we want to use OUT parameters, we have to store
somewhere &$var to load() data from LOB to it.
- IN OUT params are not working now (should not be a big problem to fix it)
- now mass binding not working too (I've wrote about it before)
</pre>
<p>Simplified Connect() and PConnect() error handling.
<p>When extension not loaded, Connect() and PConnect() will return null. On connect error, the fns will return false.
<p>CacheGetArray() added to code.
<p>Added Init() to adorecordset_empty().
<p>Changed postgres64 driver, MetaColumns() to not strip off quotes in default value if :: detected (type-casting of default).
<p>Added test: if (!defined('ADODB_DIR')) die(). Useful to prevent hackers from detecting file paths.
<p>Changed metaTablesSQL to ignore Postgres 7.4 information schemas (sql_*).
<p>New polish language file by Grzegorz Pacan
<p>Added support for UNION in _adodb_getcount().
<p>Added security check for ADODB_DIR to limit path disclosure issues. Requested by postnuke team.
<p>Added better error message support to oracle driver. Thx to Gaetano Giunta.
<p>Added showSchema support to mysql.
<p>Bind in oci8 did not handle $name=false properly. Fixed.
<p>If extension not loaded, Connect(), PConnect(), NConnect() will return null.
<p><b>4.22 15 Apr 2004</b>
<p>Moved docs to own adodb/docs folder.
<p>Fixed session bug when quoting compressed/encrypted data in Replace().
<p>Netezza Driver and LDAP drivers contributed by Josh Eldridge.
<p>GetMenu now uses rtrim() on values instead of trim().

View File

@ -18,9 +18,11 @@
<body bgcolor="#FFFFFF">
<h2>ADOdb Data Dictionary Library for PHP</h2>
<p>V4.22 15 Apr 2004 (c) 2000-2004 John Lim (<a href="mailto:jlim#natsoft.com.my">jlim#natsoft.com.my</a>).<br> AXMLS (c) 2004 ars Cognita, Inc</p>
<p>V4.50 6 July 2004 (c) 2000-2004 John Lim (<a href="mailto:jlim#natsoft.com.my">jlim#natsoft.com.my</a>).<br> AXMLS (c) 2004 ars Cognita, Inc</p>
<p><font size="1">This software is dual licensed using BSD-Style and LGPL. This means you can use it in compiled proprietary and commercial products.</font></p>
<p>Useful ADOdb links: <a href=http://php.weblogs.com/adodb?dd=1>Download</a> &nbsp; <a href=http://php.weblogs.com/adodb_manual?dd=1>Other Docs</a></p>
<table border=1><tr><td><font color=red>Kindly note that the ADOdb home page has moved to <a href=http://adodb.sourceforge.net/>http://adodb.sourceforge.net/</a> because of the persistent
unreliability of http://php.weblogs.com. <b>Please change your links</b>!</font></td></tr></table>
<p>Useful ADOdb links: <a href=http://adodb.sourceforge.net/#download>Download</a> &nbsp; <a href=http://adodb.sourceforge.net/#docs>Other Docs</a>
<p>This documentation describes a PHP class library to automate the creation of tables,
indexes and foreign key constraints portably for multiple databases. Richard Tango-Lowy and Dan Cech
@ -138,7 +140,7 @@ field size. Then optional keywords in $otheroptions:</p>
NAME C(32) CONSTRAINTS 'FOREIGN KEY REFERENCES reftable'</strong></font>
";
</pre>
<p>Note that if you have special characters in the field name (e.g. My Date), you should enclose it in back-quotes. Normally field names are not case-sensitive, but if you enclose it in back-quotes, some databases treat the names as case-sensitive, and some don't. So be careful.</p>
<p>Note that if you have special characters in the field name (e.g. My Date), you should enclose it in back-quotes. Normally field names are not case-sensitive, but if you enclose it in back-quotes, some databases will treat the names as case-sensitive (eg. Oracle) , and others won't. So be careful.</p>
<p>The $taboptarray is the 3rd parameter of the CreateTableSQL function. This contains table specific settings. Legal keywords include:</p>
<ul>

View File

@ -7,10 +7,12 @@
<body>
<h3>The ADOdb Performance Monitoring Library</h3>
<p>V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my)</p>
<p>V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my)</p>
<p><font size="1">This software is dual licensed using BSD-Style and LGPL. This
means you can use it in compiled proprietary and commercial products.</font></p>
<p>Useful ADOdb links: <a href=http://php.weblogs.com/adodb?perf=1>Download</a> &nbsp; <a href=http://php.weblogs.com/adodb_manual?perf=1>Other Docs</a>
<table border=1><tr><td><font color=red>Kindly note that the ADOdb home page has moved to <a href=http://adodb.sourceforge.net/>http://adodb.sourceforge.net/</a> because of the persistent
unreliability of http://php.weblogs.com. <b>Please change your links</b>!</font></td></tr></table>
<p>Useful ADOdb links: <a href=http://adodb.sourceforge.net/#download>Download</a> &nbsp; <a href=http://adodb.sourceforge.net/#docs>Other Docs</a>
<h3>Introduction</h3>
<p>This module, part of the ADOdb package, provides both CLI and HTML interfaces
for viewing key performance indicators of your database. This is very useful

View File

@ -11,10 +11,12 @@
<body bgcolor="#FFFFFF">
<h3>ADODB Session Management Manual</h3>
<p>
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my)
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my)
<p> <font size=1>This software is dual licensed using BSD-Style and LGPL. This
means you can use it in compiled proprietary and commercial products. </font>
<p>Useful ADOdb links: <a href=http://php.weblogs.com/adodb>Download</a> &nbsp; <a href=http://php.weblogs.com/adodb_manual>Other Docs</a>
<table border=1><tr><td><font color=red>Kindly note that the ADOdb home page has moved to <a href=http://adodb.sourceforge.net/>http://adodb.sourceforge.net/</a> because of the persistent
unreliability of http://php.weblogs.com. <b>Please change your links</b>!</font></td><tr></table>
<p>Useful ADOdb links: <a href=http://adodb.sourceforge.net/#download>Download</a> &nbsp; <a href=http://adodb.sourceforge.net/#docs>Other Docs</a>
<h3>Introduction</h3>
<p>

View File

@ -17,7 +17,7 @@
Dimension in my Mac days, to the databases I currently use, which are: Oracle,
FoxPro, Access, MS SQL Server and MySQL. Although most of the advice here applies
to using SQL with Perl, Python and other programming languages, I will focus on PHP and how
the <a href="http://php.weblogs.com/adodb">ADOdb</a> database abstraction library
the <a href="http://adodb.sourceforge.net/">ADOdb</a> database abstraction library
offers some solutions.<p></p>
<p>Most database vendors practice product lock-in. The best or fastest way to
do things is often implemented using proprietary extensions to SQL. This makes

View File

@ -1,16 +1,18 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Microsoft Access data driver. Requires ODBC. Works only on MS Windows.
*/
if (!defined('_ADODB_ODBC_LAYER')) {
if (!defined('ADODB_DIR')) die();
include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
}
if (!defined('_ADODB_ACCESS')) {

View File

@ -1,19 +1,24 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Microsoft ADO data driver. Requires ADO. Works only on MS Windows.
*/
define("_ADODB_ADO_LAYER", 1 );
// security - hide paths
if (!defined('ADODB_DIR')) die();
define("_ADODB_ADO_LAYER", 1 );
/*--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------*/
class ADODB_ado extends ADOConnection {
var $databaseType = "ado";
var $_bindInputArray = false;

View File

@ -1,16 +1,19 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Microsoft Access ADO data driver. Requires ADO and ODBC. Works only on MS Windows.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
if (!defined('_ADODB_ADO_LAYER')) {
include(ADODB_DIR."/drivers/adodb-ado.inc.php");
}

View File

@ -1,12 +1,12 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Microsoft SQL Server ADO data driver. Requires ADO and MSSQL client.
Works only on MS Windows.
@ -15,14 +15,19 @@ Set tabs to 4 for best viewing.
This file is only a technology demonstration and for test purposes.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
if (!defined('_ADODB_ADO_LAYER')) {
include(ADODB_DIR."/drivers/adodb-ado.inc.php");
}
class ADODB_ado_mssql extends ADODB_ado {
var $databaseType = 'ado_mssql';
var $hasTop = 'top';
var $sysDate = 'GetDate()';
var $hasInsertID = true;
var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)';
var $sysTimeStamp = 'GetDate()';
var $leftOuter = '*=';
var $rightOuter = '=*';
@ -48,9 +53,39 @@ class ADODB_ado_mssql extends ADODB_ado {
return $this->GetOne('select @@rowcount');
}
}
function MetaColumns($table)
{
$table = strtoupper($table);
$arr= array();
$dbc = $this->_connectionID;
class ADORecordSet_ado_mssql extends ADORecordSet_ado {
$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();
}
return $arr;
}
}
class ADORecordSet_ado_mssql extends ADORecordSet_ado {
var $databaseType = 'ado_mssql';

View File

@ -1,17 +1,20 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Support Borland Interbase 6.5 and later
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
include_once(ADODB_DIR."/drivers/adodb-ibase.inc.php");
class ADODB_borland_ibase extends ADODB_ibase {
@ -22,6 +25,15 @@ class ADODB_borland_ibase extends ADODB_ibase {
$this->ADODB_ibase();
}
function BeginTrans()
{
if ($this->transOff) return true;
$this->transCnt += 1;
$this->autoCommit = false;
$this->_transactionID = ibase_trans($this->ibasetrans, $this->_connectionID);
return $this->_transactionID;
}
function ServerInfo()
{
$arr['dialect'] = $this->dialect;

View File

@ -1,6 +1,6 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -11,6 +11,9 @@ V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights rese
Transactions not supported yet.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
if (! defined("_ADODB_CSV_LAYER")) {
define("_ADODB_CSV_LAYER", 1 );

View File

@ -1,12 +1,12 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
DB2 data driver. Requires ODBC.
@ -82,6 +82,9 @@ Connect() when using the CLI interface. From Halmai Csongor csongor.halmai#nexum
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
if (!defined('_ADODB_ODBC_LAYER')) {
include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
}

View File

@ -1,6 +1,6 @@
<?php
/*
@version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
@version V4.50 6 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.
@ -8,6 +8,9 @@
Set tabs to 8.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
if (! defined("_ADODB_FBSQL_LAYER")) {
define("_ADODB_FBSQL_LAYER", 1 );

View File

@ -1,20 +1,26 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
include_once(ADODB_DIR."/drivers/adodb-ibase.inc.php");
class ADODB_firebird extends ADODB_ibase {
var $databaseType = "firebird";
var $dialect = 3;
var $sysTimeStamp = "cast('NOW' as timestamp)";
function ADODB_firebird()
{
$this->ADODB_ibase();

View File

@ -1,11 +1,11 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Interbase data driver. Requires interbase client. Works on Windows and Unix.
@ -23,13 +23,17 @@ V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights rese
$conn->Execute("insert into table (id, col1,...) values ($id, $val1,...)");
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB_ibase extends ADOConnection {
var $databaseType = "ibase";
var $dataProvider = "ibase";
var $replaceQuote = "''"; // string to use to replace quotes
var $ibase_timefmt = '%Y-%m-%d'; // For hours,mins,secs change to '%Y-%m-%d %H:%M:%S';
var $ibase_datefmt = '%Y-%m-%d'; // For hours,mins,secs change to '%Y-%m-%d %H:%M:%S';
var $fmtDate = "'Y-m-d'";
var $ibase_timestampfmt = "%Y-%m-%d %H:%M:%S";
var $ibase_timefmt = "%H:%M:%S";
var $fmtTimeStamp = "'Y-m-d, H:i:s'";
var $concat_operator='||';
var $_transactionID;
@ -42,7 +46,7 @@ class ADODB_ibase extends ADOConnection {
var $_bindInputArray = true;
var $buffers = 0;
var $dialect = 1;
var $sysDate = "cast('TODAY' as date)";
var $sysDate = "cast('TODAY' as timestamp)";
var $sysTimeStamp = "cast('NOW' as timestamp)";
var $ansiOuter = true;
var $hasAffectedRows = false;
@ -109,6 +113,23 @@ class ADODB_ibase extends ADOConnection {
return $ret;
}
// there are some compat problems with ADODB_COUNTRECS=false and $this->_logsql currently.
// it appears that ibase extension cannot support multiple concurrent queryid's
function &_Execute($sql,$inputarr=false)
{
global $ADODB_COUNTRECS;
if ($this->_logsql) {
$savecrecs = $ADODB_COUNTRECS;
$ADODB_COUNTRECS = true; // force countrecs
$ret =& ADOConnection::_Execute($sql,$inputarr);
$ADODB_COUNTRECS = $savecrecs;
} else {
$ret =& ADOConnection::_Execute($sql,$inputarr);
}
return $ret;
}
function RollbackTrans()
{
if ($this->transOff) return true;
@ -237,11 +258,14 @@ class ADODB_ibase extends ADOConnection {
}
// returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$persist=false)
{
if (!function_exists('ibase_pconnect')) return false;
if (!function_exists('ibase_pconnect')) return null;
if ($argDatabasename) $argHostname .= ':'.$argDatabasename;
$this->_connectionID = ibase_connect($argHostname,$argUsername,$argPassword,$this->charSet,$this->buffers,$this->dialect);
$fn = ($persist) ? 'ibase_pconnect':'ibase_connect';
$this->_connectionID = $fn($argHostname,$argUsername,$argPassword,
$this->charSet,$this->buffers,$this->dialect);
if ($this->dialect != 1) { // http://www.ibphoenix.com/ibp_60_del_id_ds.html
$this->replaceQuote = "''";
}
@ -250,25 +274,29 @@ class ADODB_ibase extends ADOConnection {
return false;
}
ibase_timefmt($this->ibase_timefmt);
// PHP5 change.
if (function_exists('ibase_timefmt')) {
ibase_timefmt($this->ibase_datefmt,IBASE_DATE );
if ($this->dialect == 1) ibase_timefmt($this->ibase_datefmt,IBASE_TIMESTAMP );
else ibase_timefmt($this->ibase_timestampfmt,IBASE_TIMESTAMP );
ibase_timefmt($this->ibase_timefmt,IBASE_TIME );
} else {
ini_set("ibase.timestampformat", $this->base_timestampfmt);
ini_set("ibase.dateformat", $this->ibase_datefmt);
ini_set("ibase.timeformat", $this->ibase_timefmt);
}
//you can use
/*
ini_set("ibase.timestampformat", $this->ibase_timestampfmt);
ini_set("ibase.dateformat", $this->ibase_datefmt);
ini_set("ibase.timeformat", $this->ibase_timefmt);
*/
return true;
}
// returns true or false
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if (!function_exists('ibase_pconnect')) return false;
if ($argDatabasename) $argHostname .= ':'.$argDatabasename;
$this->_connectionID = ibase_pconnect($argHostname,$argUsername,$argPassword,$this->charSet,$this->buffers,$this->dialect);
if ($this->dialect != 1) { // http://www.ibphoenix.com/ibp_60_del_id_ds.html
$this->replaceQuote = "''";
}
if ($this->_connectionID === false) {
$this->_handleerror();
return false;
}
ibase_timefmt($this->ibase_timefmt);
return true;
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,true);
}
function Prepare($sql)
@ -293,7 +321,6 @@ class ADODB_ibase extends ADOConnection {
if (is_array($sql)) {
$fn = 'ibase_execute';
$sql = $sql[1];
if (is_array($iarr)) {
if (ADODB_PHPVER >= 0x4050) { // actually 4.0.4
if ( !isset($iarr[0]) ) $iarr[0] = ''; // PHP5 compat hack
@ -318,7 +345,7 @@ class ADODB_ibase extends ADOConnection {
if (is_array($iarr)) {
if (ADODB_PHPVER >= 0x4050) { // actually 4.0.4
if ( !isset($iarr[0]) ) $iarr[0] = ''; // PHP5 compat hack
if (sizeof($iarr) == 0) $iarr[0] = ''; // PHP5 compat hack
$fnarr =& array_merge( array($conn,$sql) , $iarr);
$ret = call_user_func_array($fn,$fnarr);
} else {
@ -350,7 +377,7 @@ class ADODB_ibase extends ADOConnection {
}
//OPN STUFF start
function _ConvertFieldType(&$fld, $ftype, $flen, $fscale, $fsubtype, $fprecision, $isInterbase6)
function _ConvertFieldType(&$fld, $ftype, $flen, $fscale, $fsubtype, $fprecision, $dialect3)
{
$fscale = abs($fscale);
$fld->max_length = $flen;
@ -358,7 +385,7 @@ class ADODB_ibase extends ADOConnection {
switch($ftype){
case 7:
case 8:
if ($isInterbase6) {
if ($dialect3) {
switch($fsubtype){
case 0:
$fld->type = ($ftype == 7 ? 'smallint' : 'integer');
@ -385,7 +412,7 @@ class ADODB_ibase extends ADOConnection {
}
break;
case 16:
if ($isInterbase6) {
if ($dialect3) {
switch($fsubtype){
case 0:
$fld->type = 'decimal';
@ -421,16 +448,18 @@ class ADODB_ibase extends ADOConnection {
}
break;
case 35:
if ($isInterbase6) {
if ($dialect3) {
$fld->type = 'timestamp';
} else {
$fld->type = 'date';
}
break;
case 12:
case 13:
$fld->type = 'date';
break;
case 13:
$fld->type = 'time';
break;
case 37:
$fld->type = 'varchar';
break;
@ -461,13 +490,13 @@ class ADODB_ibase extends ADOConnection {
$retarr = array();
//OPN STUFF start
$isInterbase6 = ($this->dialect==3 ? true : false);
$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], $isInterbase6);
$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;
}
@ -678,7 +707,7 @@ class ADORecordset_ibase extends ADORecordSet
global $ADODB_FETCH_MODE;
$this->fetchMode = ($mode === false) ? $ADODB_FETCH_MODE : $mode;
return $this->ADORecordSet($id);
$this->ADORecordSet($id);
}
/* Returns: an object containing field information.
@ -690,10 +719,28 @@ class ADORecordset_ibase extends ADORecordSet
{
$fld = new ADOFieldObject;
$ibf = ibase_field_info($this->_queryID,$fieldOffset);
switch (ADODB_ASSOC_CASE) {
case 2: // the default
$fld->name = ($ibf['alias']);
if (empty($fld->name)) $fld->name = ($ibf['name']);
break;
case 0:
$fld->name = strtoupper($ibf['alias']);
if (empty($fld->name)) $fld->name = strtoupper($ibf['name']);
break;
case 1:
$fld->name = strtolower($ibf['alias']);
if (empty($fld->name)) $fld->name = strtolower($ibf['name']);
break;
}
$fld->type = $ibf['type'];
$fld->max_length = $ibf['length'];
/* This needs to be populated from the metadata */
$fld->not_null = false;
$fld->has_default = false;
$fld->default_value = 'null';
return $fld;
}
@ -714,8 +761,6 @@ class ADORecordset_ibase extends ADORecordSet
return false;
}
function _fetch()
{
$f = @ibase_fetch_row($this->_queryID);
@ -799,7 +844,7 @@ class ADORecordset_ibase extends ADORecordSet
case 'TIMESTAMP':
case 'DATE': return 'D';
case 'TIME': return 'T';
//case 'T': return 'T';
//case 'L': return 'L';

View File

@ -1,6 +1,6 @@
<?php
/**
* @version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
* @version V4.50 6 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.
@ -12,6 +12,10 @@
* Informix 9 driver that supports SELECT FIRST
*
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
include_once(ADODB_DIR.'/drivers/adodb-informix72.inc.php');
class ADODB_informix extends ADODB_informix72 {

View File

@ -1,12 +1,12 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim. All rights reserved.
V4.50 6 July 2004 (c) 2000-2004 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.
Set tabs to 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Informix port by Mitchell T. Young (mitch@youngfamily.org)
@ -14,6 +14,9 @@ V4.22 15 Apr 2004 (c) 2000-2004 John Lim. All rights reserved.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
if (!defined('IFX_SCROLL')) define('IFX_SCROLL',1);
class ADODB_informix72 extends ADOConnection {
@ -26,13 +29,21 @@ class ADODB_informix72 extends ADOConnection {
var $hasAffectedRows = true;
var $upperCase = 'upper';
var $substr = 'substr';
var $metaTablesSQL="select tabname from systables";
var $metaColumnsSQL =
"select c.colname, c.coltype, c.collength, d.default
from syscolumns c, systables t,sysdefaults d
where c.tabid=t.tabid and d.tabid=t.tabid and d.colno=c.colno and tabname='%s'";
var $metaTablesSQL="select tabname from systables where tabtype!=' ' and owner!='informix'"; //Don't get informix tables and pseudo-tables
var $metaColumnsSQL =
"select c.colname, c.coltype, c.collength, d.default,c.colno
from syscolumns c, systables t,outer sysdefaults d
where c.tabid=t.tabid and d.tabid=t.tabid and d.colno=c.colno
and tabname='%s' order by c.colno";
var $metaPrimaryKeySQL =
"select part1,part2,part3,part4,part5,part6,part7,part8 from
systables t,sysconstraints s,sysindexes i where t.tabname='%s'
and s.tabid=t.tabid and s.constrtype='P'
and i.idxname=s.idxname";
// var $metaColumnsSQL = "select colname, coltype, collength from syscolumns c, systables t where c.tabid=t.tabid and tabname='%s'";
var $concat_operator = '||';
var $lastQuery = false;
@ -149,12 +160,14 @@ class ADODB_informix72 extends ADOConnection {
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
if ($rs === false) return false;
$rspkey = $this->Execute(sprintf($this->metaPrimaryKeySQL,$table)); //Added to get primary key colno items
$retarr = array();
while (!$rs->EOF) { //print_r($rs->fields);
$fld = new ADOFieldObject();
$fld->name = $rs->fields[0];
$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];
if (trim($rs->fields[3]) != "AAAAAA 0") {
$fld->has_default = 1;
@ -194,7 +207,7 @@ class ADODB_informix72 extends ADOConnection {
// returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if (!function_exists('ifx_connect')) return false;
if (!function_exists('ifx_connect')) return null;
$dbs = $argDatabasename . "@" . $argHostname;
if ($argHostname) putenv("INFORMIXSERVER=$argHostname");
@ -208,7 +221,7 @@ class ADODB_informix72 extends ADOConnection {
// returns true or false
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if (!function_exists('ifx_connect')) return false;
if (!function_exists('ifx_connect')) return null;
$dbs = $argDatabasename . "@" . $argHostname;
putenv("INFORMIXSERVER=".trim($argHostname));

View File

@ -1,6 +1,6 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -10,6 +10,8 @@
Joshua Eldridge (joshuae74#hotmail.com)
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB_ldap extends ADOConnection {
var $databaseType = 'ldap';
@ -34,7 +36,7 @@ class ADODB_ldap extends ADOConnection {
function _connect( $host, $username, $password, $ldapbase )
{
if ( !function_exists( 'ldap_connect' ) ) return false;
if ( !function_exists( 'ldap_connect' ) ) return null;
$conn_info = array( $host );

View File

@ -1,12 +1,12 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Native mssql driver. Requires mssql client. Works on Windows.
To configure for Unix, see
@ -14,6 +14,9 @@ Set tabs to 4 for best viewing.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
//----------------------------------------------------------------
// MSSQL returns dates with the format Oct 13 2002 or 13 Oct 2002
// and this causes tons of problems because localized versions of
@ -435,7 +438,7 @@ order by constraint_name, referenced_table_name, keyno";
// returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if (!function_exists('mssql_pconnect')) return false;
if (!function_exists('mssql_pconnect')) return null;
$this->_connectionID = mssql_connect($argHostname,$argUsername,$argPassword);
if ($this->_connectionID === false) return false;
if ($argDatabasename) return $this->SelectDB($argDatabasename);
@ -446,7 +449,7 @@ order by constraint_name, referenced_table_name, keyno";
// returns true or false
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if (!function_exists('mssql_pconnect')) return false;
if (!function_exists('mssql_pconnect')) return null;
$this->_connectionID = mssql_pconnect($argHostname,$argUsername,$argPassword);
if ($this->_connectionID === false) return false;
@ -771,7 +774,7 @@ class ADORecordset_mssql extends ADORecordSet {
$this->fields = @mssql_fetch_assoc($this->_queryID);
else {
$this->fields = @mssql_fetch_array($this->_queryID);
if (is_array($$this->fields)) {
if (@is_array($$this->fields)) {
$fassoc = array();
foreach($$this->fields as $k => $v) {
if (is_integer($k)) continue;

View File

@ -1,6 +1,6 @@
<?php
/**
* @version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
* @version V4.50 6 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.
@ -13,6 +13,9 @@
*
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
/*
The big difference between mssqlpo and it's parent mssql is that mssqlpo supports

View File

@ -1,6 +1,6 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -12,6 +12,9 @@ V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights rese
28 Feb 2001: MetaColumns bug fix - suggested by Freek Dijkstra (phpeverywhere@macfreek.com)
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
if (! defined("_ADODB_MYSQL_LAYER")) {
define("_ADODB_MYSQL_LAYER", 1 );
@ -55,16 +58,18 @@ class ADODB_mysql extends ADOConnection {
function &MetaTables($ttype=false,$showSchema=false,$mask=false)
{
if ($mask) {
$save = $this->metaTablesSQL;
if ($showSchema && is_string($showSchema)) {
$this->metaTablesSQL .= " from $showSchema";
}
if ($mask) {
$mask = $this->qstr($mask);
$this->metaTablesSQL .= " like $mask";
}
$ret =& ADOConnection::MetaTables($ttype,$showSchema);
if ($mask) {
$this->metaTablesSQL = $save;
}
return $ret;
}
@ -148,13 +153,16 @@ class ADODB_mysql extends ADOConnection {
function GetOne($sql,$inputarr=false)
{
if (strncasecmp($sql,'sele',4) == 0) {
$rs =& $this->SelectLimit($sql,1,-1,$inputarr);
if ($rs) {
$rs->Close();
if ($rs->EOF) return false;
return reset($rs->fields);
}
} else {
return ADOConnection::GetOne($sql,$inputarr);
}
return false;
}
@ -431,6 +439,8 @@ class ADODB_mysql extends ADOConnection {
function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0)
{
$offsetStr =($offset>=0) ? "$offset," : '';
// jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220
if ($nrows < 0) $nrows = '18446744073709551615';
if ($secs)
$rs =& $this->CacheExecute($secs,$sql." LIMIT $offsetStr$nrows",$inputarr);
@ -532,7 +542,6 @@ class ADORecordSet_mysql extends ADORecordSet{
function &FetchField($fieldOffset = -1)
{
if ($fieldOffset != -1) {
$o = @mysql_fetch_field($this->_queryID, $fieldOffset);
$f = @mysql_field_flags($this->_queryID,$fieldOffset);

View File

@ -1,6 +1,6 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -12,8 +12,12 @@ V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights rese
21 October 2003: MySQLi extension implementation by Arjen de Rijke (a.de.rijke@xs4all.nl)
Based on adodb 3.40
*/
if (! defined("_ADODB_MYSQL_LAYER")) {
define("_ADODB_MYSQL_LAYER", 1 );
// security - hide paths
//if (!defined('ADODB_DIR')) die();
if (! defined("_ADODB_MYSQLI_LAYER")) {
define("_ADODB_MYSQLI_LAYER", 1 );
class ADODB_mysqli extends ADOConnection {
var $databaseType = 'mysqli';
@ -34,8 +38,8 @@ class ADODB_mysqli extends ADOConnection {
var $forceNewConnect = false;
var $poorAffectedRows = true;
var $clientFlags = 0;
var $executeOnly = true;
var $substr = "substring";
//var $poorAffectedRows = true;
var $nameQuote = '`'; /// string to use to quote identifiers and names
//var $_bindInputArray = true;
@ -102,19 +106,11 @@ class ADODB_mysqli extends ADOConnection {
function qstr($s, $magic_quotes = false)
{
if (!$magic_quotes) {
if (ADODB_PHPVER >= 0x5000) {
// $this->_connectionID = $this->mysqli_resolve_link($this->_connectionID);
if (PHP_VERSION >= 5)
return "'" . mysqli_real_escape_string($this->_connectionID, $s) . "'";
}
else
{
trigger_error("phpver < 5 not implemented", E_USER_ERROR);
}
if ($this->replaceQuote[0] == '\\')
{
$s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
}
return "'".str_replace("'",$this->replaceQuote,$s)."'";
}
// undo magic quotes for "
@ -636,6 +632,7 @@ class ADORecordSet_mysqli extends ADORecordSet{
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
}
switch ($mode)
{
case ADODB_FETCH_NUM:
@ -647,31 +644,26 @@ class ADORecordSet_mysqli extends ADORecordSet{
case ADODB_FETCH_DEFAULT:
case ADODB_FETCH_BOTH:
default:
$this->fetchMode = MYSQLI_ASSOC;
$this->fetchMode = MYSQLI_BOTH;
break;
}
$this->ADORecordSet($queryID);
}
function _initrs()
{
// mysqli_num_rows only return correct number, depens
// on the use of mysql_store_result and mysql_use_result
if (!$this->Connection->executeOnly) {
$this->_numOfRows = @mysqli_num_rows($this->_queryID);
global $ADODB_COUNTRECS;
$this->_numOfRows = $ADODB_COUNTRECS ? @mysqli_num_rows($this->_queryID) : -1;
$this->_numOfFields = @mysqli_num_fields($this->_queryID);
}
else {
$this->_numOfRows = 0;
$this->_numOfFields = 0;
}
}
function &FetchField($fieldOffset = -1)
{
$fieldnr = $fieldOffset;
if ($fieldOffset != -1) {
$fieldOffset = mysqi_field_seek($this->_queryID, $fieldnr);
$fieldOffset = mysqli_field_seek($this->_queryID, $fieldnr);
}
$o = mysqli_fetch_field($this->_queryID);
return $o;
@ -719,36 +711,18 @@ class ADORecordSet_mysqli extends ADORecordSet{
// Other functions return no or the wrong results.
function MoveNext()
{
if ($this->EOF)
return false;
if ($this->EOF) return false;
$this->_currentRow++;
switch($this->fetchMode)
{
case MYSQLI_NUM:
$this->fields = mysqli_fetch_array($this->_queryID);
break;
case MYSQLI_ASSOC:
case MYSQLI_BOTH:
$this->fields = mysqli_fetch_assoc($this->_queryID);
break;
default:
}
if (is_array($this->fields))
return true;
$this->fields = mysqli_fetch_array($this->_queryID,$this->fetchMode);
if (is_array($this->fields)) return true;
$this->EOF = true;
return false;
}
function _fetch()
{
// mysqli_fetch_array($this->_queryID, MYSQLI_NUM) does not
// work (22-10-2003). But mysqli_fetch_array($this->_queryID) gives
// int resulttype should default to MYSQLI_BOTH,but give MYSQLI_NUM.
// $this->fields = mysqli_fetch_fields($this->_queryID);
// $this->fields = mysqli_fetch_array($this->_queryID); //, $this->fetchMode);
$this->fields = mysqli_fetch_assoc($this->_queryID); // $this->fetchMode);
$this->fields = mysqli_fetch_array($this->_queryID,$this->fetchMode);
return is_array($this->fields);
}

View File

@ -1,7 +1,7 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -13,6 +13,8 @@ V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights rese
Requires mysql client. Works on Windows and Unix.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
include_once(ADODB_DIR."/drivers/adodb-mysql.inc.php");
@ -21,6 +23,7 @@ class ADODB_mysqlt extends ADODB_mysql {
var $databaseType = 'mysqlt';
var $ansiOuter = true; // for Version 3.23.17 or later
var $hasTransactions = true;
var $autoRollback = true; // apparently mysql does not autorollback properly
function BeginTrans()
{

View File

@ -1,6 +1,6 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved.
V4.50 6 July 2004 (c) 2000-2004 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.
@ -14,7 +14,8 @@
Updated public variables for Netezza
Still need to remove blob functions, as Netezza doesn't suppport blob
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
include_once(ADODB_DIR.'/drivers/adodb-postgres64.inc.php');

View File

@ -1,19 +1,22 @@
<?php
/*
version V4.22 15 Apr 2004 (c) 2000-2004 John Lim. All rights reserved.
version V4.50 6 July 2004 (c) 2000-2004 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.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Code contributed by George Fourlanos <fou@infomap.gr>
13 Nov 2000 jlim - removed all ora_* references.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
/*
NLS_Date_Format
Allows you to use a date format other than the Oracle Lite default. When a literal
@ -35,6 +38,20 @@ NLS_DATE_FORMAT='RR-MM-DD'
You can also modify the date format using the ALTER SESSION command.
*/
# define the LOB descriptor type for the given type
# returns false if no LOB descriptor
function oci_lob_desc($type) {
switch ($type) {
case OCI_B_BFILE: $result = OCI_D_FILE; break;
case OCI_B_CFILEE: $result = OCI_D_FILE; break;
case OCI_B_CLOB: $result = OCI_D_LOB; break;
case OCI_B_BLOB: $result = OCI_D_LOB; break;
case OCI_B_ROWID: $result = OCI_D_ROWID; break;
default: $result = false; break;
}
return $result;
}
class ADODB_oci8 extends ADOConnection {
var $databaseType = 'oci8';
var $dataProvider = 'oci8';
@ -67,6 +84,7 @@ class ADODB_oci8 extends ADOConnection {
var $NLS_DATE_FORMAT = 'YYYY-MM-DD'; // To include time, use 'RRRR-MM-DD HH24:MI:SS'
var $useDBDateFormatForTextInput=false;
var $datetime = false; // MetaType('DATE') returns 'D' (datetime==false) or 'T' (datetime == true)
var $_refLOBs = array();
// var $ansiOuter = true; // if oracle9
@ -156,7 +174,7 @@ NATSOFT.DOMAIN =
*/
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$mode=0)
{
if (!function_exists('OCIPLogon')) return false;
if (!function_exists('OCIPLogon')) return null;
$this->_errorMsg = false;
@ -680,8 +698,9 @@ NATSOFT.DOMAIN =
Note that the order of parameters differs from OCIBindByName,
because we default the names to :0, :1, :2
*/
function Bind(&$stmt,&$var,$size=4000,$type=false,$name=false)
function Bind(&$stmt,&$var,$size=4000,$type=false,$name=false,$isOutput=false)
{
if (!is_array($stmt)) return false;
if (($type == OCI_B_CURSOR) && sizeof($stmt) >= 5) {
@ -689,15 +708,39 @@ NATSOFT.DOMAIN =
}
if ($name == false) {
if ($type !== false) $rez = OCIBindByName($stmt[1],":".$name,$var,$size,$type);
if ($type !== false) $rez = OCIBindByName($stmt[1],":".$stmt[2],$var,$size,$type);
else $rez = OCIBindByName($stmt[1],":".$stmt[2],$var,$size); // +1 byte for null terminator
$stmt[2] += 1;
} else if ($type == OCI_B_BLOB){
} else if (oci_lob_desc($type)) {
if ($this->debug) {
ADOConnection::outp("<b>Bind</b>: name = $name");
}
//we have to create a new Descriptor here
$_blob = OCINewDescriptor($this->_connectionID, OCI_D_LOB);
$rez = OCIBindByName($stmt[1], ":".$name, &$_blob, -1, OCI_B_BLOB);
$rez = $_blob;
$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'];
$rez = OCIBindByName($stmt[1], ":".$name, $tmp, -1, $type);
if ($this->debug) {
ADOConnection::outp("<b>Bind</b>: descriptor has been allocated, var binded");
}
// if type is input then write data to lob now
if ($isOutput == false) {
$var = $this -> BlobEncode($var);
$tmp -> WriteTemporary($var);
if ($this->debug) {
ADOConnection::outp("<b>Bind</b>: LOB has been written to temp");
}
} else {
$this -> _refLOBs[$numlob]['VAR'] = &$var;
}
$rez = $tmp;
} else {
if ($this->debug)
ADOConnection::outp("<b>Bind</b>: name = $name");
if ($type !== false) $rez = OCIBindByName($stmt[1],":".$name,$var,$size,$type);
else $rez = OCIBindByName($stmt[1],":".$name,$var,$size); // +1 byte for null terminator
}
@ -733,7 +776,7 @@ NATSOFT.DOMAIN =
$ztype = (empty($type)) ? 'false' : $type;
ADOConnection::outp( "{$prefix}Parameter(\$stmt, \$php_var='$var', \$name='$name', \$maxLen=$maxLen, \$type=$ztype);");
}
return $this->Bind($stmt,$var,$maxLen,$type,$name);
return $this->Bind($stmt,$var,$maxLen,$type,$name,$isOutput);
}
/*
@ -807,6 +850,22 @@ NATSOFT.DOMAIN =
$this->_errorMsg = false;
$this->_errorCode = false;
if (OCIExecute($stmt,$this->_commit)) {
//OCIInternalDebug(1);
if (count($this -> _refLOBs) > 0) {
foreach ($this -> _refLOBs as $key => $value) {
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>");
}
//$_GLOBALS[$this -> _refLOBs[$key]['VAR']] = $tmp;
$this -> _refLOBs[$key]['VAR'] = $tmp;
}
$this -> _refLOBs[$key]['LOB'] -> free();
unset($this -> _refLOBs[$key]);
}
}
switch (@OCIStatementType($stmt)) {
case "SELECT":
@ -840,6 +899,12 @@ NATSOFT.DOMAIN =
function _close()
{
if (!$this->autoCommit) OCIRollback($this->_connectionID);
if (count($this -> _refLOBs) > 0) {
foreach ($this -> _refLOBs as $key => $value) {
$this -> _refLOBs[$key] -> free();
unset($this -> _refLOBs[$key]);
}
}
OCILogoff($this->_connectionID);
$this->_stmt = false;
$this->_connectionID = false;
@ -944,7 +1009,6 @@ SELECT /*+ RULE */ distinct b.column_name
{
$nofixquotes=false;
if (is_array($s)) adodb_backtrace();
if ($this->noNullStrings && strlen($s)==0)$s = ' ';
if (!$magic_quotes) {
if ($this->replaceQuote[0] == '\\'){
@ -956,12 +1020,9 @@ SELECT /*+ RULE */ distinct b.column_name
// undo magic quotes for "
$s = str_replace('\\"','"',$s);
if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything
return "'$s'";
else {// change \' to '' for sybase/mssql
$s = str_replace('\\\\','\\',$s);
return "'".str_replace("\\'",$this->replaceQuote,$s)."'";
}
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
* @version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
* @version V4.50 6 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.
@ -12,6 +12,9 @@
* Oracle 8.0.5 driver
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
include_once(ADODB_DIR.'/drivers/adodb-oci8.inc.php');
class ADODB_oci805 extends ADODB_oci8 {

View File

@ -1,11 +1,11 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim. All rights reserved.
V4.50 6 July 2004 (c) 2000-2004 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.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Portable version of oci8 driver, to make it more similar to other database drivers.
The main differences are
@ -17,6 +17,9 @@ V4.22 15 Apr 2004 (c) 2000-2004 John Lim. All rights reserved.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
include_once(ADODB_DIR.'/drivers/adodb-oci8.inc.php');
class ADODB_oci8po extends ADODB_oci8 {

View File

@ -1,15 +1,18 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved.
V4.50 6 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 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Requires ODBC. Works on Windows and Unix.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
define("_ADODB_ODBC_LAYER", 2 );
/*--------------------------------------------------------------------------------------
@ -157,15 +160,15 @@ class ADODB_odbc extends ADOConnection {
{
global $php_errormsg;
if (!function_exists('odbc_connect')) return false;
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.");
}
$php_errormsg = '';
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 = $php_errormsg;
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
if (isset($this->connectStmt)) $this->Execute($this->connectStmt);
//if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
@ -177,9 +180,10 @@ class ADODB_odbc extends ADOConnection {
{
global $php_errormsg;
if (!function_exists('odbc_connect')) return false;
if (!function_exists('odbc_connect')) return null;
$php_errormsg = '';
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.");
}
@ -187,7 +191,7 @@ class ADODB_odbc extends ADOConnection {
if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword);
else $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,$this->curmode);
$this->_errorMsg = $php_errormsg;
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
if ($this->_connectionID && $this->autoRollback) @odbc_rollback($this->_connectionID);
if (isset($this->connectStmt)) $this->Execute($this->connectStmt);
@ -466,7 +470,7 @@ class ADODB_odbc extends ADOConnection {
function _query($sql,$inputarr=false)
{
GLOBAL $php_errormsg;
$php_errormsg = '';
if (isset($php_errormsg)) $php_errormsg = '';
$this->_error = '';
if ($inputarr) {
@ -476,7 +480,7 @@ class ADODB_odbc extends ADOConnection {
$stmtid = odbc_prepare($this->_connectionID,$sql);
if ($stmtid == false) {
$this->_errorMsg = $php_errormsg;
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
return false;
}
}
@ -518,13 +522,13 @@ class ADODB_odbc extends ADOConnection {
$this->_errorMsg = '';
$this->_errorCode = 0;
} else
$this->_errorMsg = $php_errormsg;
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
} else {
if ($this->_haserrorfunctions) {
$this->_errorMsg = odbc_errormsg();
$this->_errorCode = odbc_error();
} else
$this->_errorMsg = $php_errormsg;
$this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
}
return $stmtid;
}

View File

@ -1,17 +1,20 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
MSSQL support via ODBC. Requires ODBC. Works on Windows and Unix.
For Unix configuration, see http://phpbuilder.com/columns/alberto20000919.php3
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
if (!defined('_ADODB_ODBC_LAYER')) {
include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
}

View File

@ -1,15 +1,17 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Oracle support via ODBC. Requires ODBC. Works on Windows.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
if (!defined('_ADODB_ODBC_LAYER')) {
include(ADODB_DIR."/drivers/adodb-odbc.inc.php");

View File

@ -1,14 +1,17 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
*/
// Code contributed by "stefan bogdan" <sbogdan#rsb.ro>
// security - hide paths
if (!defined('ADODB_DIR')) die();
define("_ADODB_ODBTP_LAYER", 2 );
class ADODB_odbtp extends ADOConnection{

View File

@ -1,15 +1,18 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
*/
// Code contributed by "Robert Twitty" <rtwitty#neutron.ushmm.org>
// security - hide paths
if (!defined('ADODB_DIR')) die();
/*
Because the ODBTP server sends and reads UNICODE text data using UTF-8
encoding, the following HTML meta tag must be included within the HTML

View File

@ -1,18 +1,20 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Oracle data driver. Requires Oracle client. Works on Windows and Unix and Oracle 7 and 8.
If you are using Oracle 8, use the oci8 driver which is much better and more reliable.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB_oracle extends ADOConnection {
var $databaseType = "oracle";
var $replaceQuote = "''"; // string to use to replace quotes
@ -39,6 +41,7 @@ class ADODB_oracle extends ADOConnection {
// format and return date string in database timestamp format
function DBTimeStamp($ts)
{
if (is_string($ts)) $d = ADORecordSet::UnixTimeStamp($ts);
return 'TO_DATE('.adodb_date($this->fmtTimeStamp,$ts).",'RRRR-MM-DD, HH:MI:SS AM')";
}
@ -72,16 +75,21 @@ class ADODB_oracle extends ADOConnection {
/* there seems to be a bug in the oracle extension -- always returns ORA-00000 - no error */
function ErrorMsg()
{
$this->_errorMsg = @ora_error($this->_curs);
if (!$this->_errorMsg) $this->_errorMsg = @ora_error($this->_connectionID);
if ($this->_errorMsg !== false) return $this->_errorMsg;
if (is_resource($this->_curs)) $this->_errorMsg = @ora_error($this->_curs);
if (empty($this->_errorMsg)) $this->_errorMsg = @ora_error($this->_connectionID);
return $this->_errorMsg;
}
function ErrorNo()
{
$err = @ora_errorcode($this->_curs);
if (!$err) return @ora_errorcode($this->_connectionID);
if ($this->_errorCode !== false) return $this->_errorCode;
if (is_resource($this->_curs)) $this->_errorCode = @ora_errorcode($this->_curs);
if (empty($this->_errorCode)) $this->_errorCode = @ora_errorcode($this->_connectionID);
return $this->_errorCode;
}
@ -89,6 +97,12 @@ class ADODB_oracle extends ADOConnection {
// returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename, $mode=0)
{
if (!function_exists('ora_plogon')) return null;
// <G. Giunta 2003/03/03/> Reset error messages before connecting
$this->_errorMsg = false;
$this->_errorCode = false;
// G. Giunta 2003/08/13 - This looks danegrously suspicious: why should we want to set
// the oracle home to the host name of remote DB?
// if ($argHostname) putenv("ORACLE_HOME=$argHostname");
@ -143,13 +157,21 @@ class ADODB_oracle extends ADOConnection {
// returns query ID if successful, otherwise false
function _query($sql,$inputarr=false)
{
// <G. Giunta 2003/03/03/> Reset error messages before executing
$this->_errorMsg = false;
$this->_errorCode = false;
$curs = ora_open($this->_connectionID);
if ($curs === false) return false;
$this->_curs = $curs;
if (!ora_parse($curs,$sql)) return false;
if (ora_exec($curs)) return $curs;
// <G. Giunta 2004/03/03> before we close the cursor, we have to store the error message
// that we can obtain ONLY from the cursor (and not from the connection)
$this->_errorCode = @ora_errorcode($curs);
$this->_errorMsg = @ora_error($curs);
// </G. Giunta 2004/03/03>
@ora_close($curs);
return false;
}

View File

@ -0,0 +1,319 @@
<?php
/*
V4.50 6 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 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net
Requires ODBC. Works on Windows and Unix.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
/*--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------*/
class ADODB_pdo extends ADOConnection {
var $databaseType = "pdo";
var $dataProvider = "pdo";
var $fmtDate = "'Y-m-d'";
var $fmtTimeStamp = "'Y-m-d, h:i:sA'";
var $replaceQuote = "''"; // string to use to replace quotes
var $hasAffectedRows = true;
var $_bindInputArray = true;
var $_genSeqSQL = "create table %s (id integer)";
var $_autocommit = true;
var $_haserrorfunctions = true;
var $_lastAffectedRows = 0;
var $stmt = false;
function ADODB_pdo()
{
}
// returns true or false
function _connect($argDSN, $argUsername, $argPassword, $argDatabasename, $persist=false)
{
$this->_connectionID = new PDO($argDSN, $argUsername, $argPassword);
if ($this->_connectionID) {
switch(ADODB_ASSOC_CASE){
case 0: $m = PDO_CASE_LOWER; break;
case 1: $m = PDO_CASE_UPPER; break;
default:
case 2: $m = PDO_CASE_NATURAL; break;
}
//$this->_connectionID->setAttribute(PDO_ATTR_ERRMODE,PDO_ERRMODE_SILENT );
$this->_connectionID->setAttribute(PDO_ATTR_CASE,$m);
//$this->_connectionID->setAttribute(PDO_ATTR_AUTOCOMMIT,true);
return true;
}
return false;
}
// returns true or false
function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
{
return $this->_connect($argDSN, $argUsername, $argPassword, $argDatabasename, true);
}
function ErrorMsg()
{
if ($this->_stmt) $arr = $this->_stmt->errorInfo();
else $arr = $this->_connectionID->errorInfo();
if ($arr) {
if ($arr[0]) return $arr[2];
else return '';
} else return '-1';
}
function InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false)
{
$obj = $stmt[1];
if ($type) $obj->bindParam($name,$var,$type,$maxLen);
else $obj->bindParam($name, $var);
}
function ErrorNo()
{
if ($this->_stmt) return $this->_stmt->errorCode();
else return $this->_connectionID->errorInfo();
}
function BeginTrans()
{
if (!$this->hasTransactions) return false;
if ($this->transOff) return true;
$this->transCnt += 1;
$this->_autocommit = false;
$this->_connectionID->setAttribute(PDO_ATTR_AUTOCOMMIT,false);
return $this->_connectionID->beginTransaction();
}
function CommitTrans($ok=true)
{
if ($this->transOff) return true;
if (!$ok) return $this->RollbackTrans();
if ($this->transCnt) $this->transCnt -= 1;
$this->_autocommit = true;
$ret = $this->_connectionID->commit();
$this->_connectionID->setAttribute(PDO_ATTR_AUTOCOMMIT,true);
return $ret;
}
function RollbackTrans()
{
if ($this->transOff) return true;
if ($this->transCnt) $this->transCnt -= 1;
$this->_autocommit = true;
$ret = $this->_connectionID->rollback();
$this->_connectionID->setAttribute(PDO_ATTR_AUTOCOMMIT,true);
return $ret;
}
function Prepare($sql)
{
$this->_stmt = $this->_connectionID->prepare($sql);
if ($this->_stmt) return array($sql,$this->_stmt);
return false;
}
function PrepareStmt($sql)
{
$stmt = $this->_connectionID->prepare($sql);
if (!$stmt) return false;
$obj = new ADOPDOStatement($stmt,$this);
return $obj;
}
/* returns queryID or false */
function _query($sql,$inputarr=false)
{
if (is_array($sql)) {
$stmt = $sql[1];
} else {
$stmt = $this->_connectionID->prepare($sql);
}
if ($stmt) {
if ($inputarr) $stmt->execute($inputarr);
else $stmt->execute();
}
$this->_stmt = $stmt;
return $stmt;
}
// returns true or false
function _close()
{
$this->_stmt = false;
return true;
}
function _affectedrows()
{
return ($this->_stmt) ? $this->_stmt->rowCount() : 0;
}
function _insertid()
{
return ($this->_connectionID) ? $this->_connectionID->lastInsertId() : 0;
}
}
class ADOPDOStatement {
var $databaseType = "pdo";
var $dataProvider = "pdo";
var $_stmt;
var $_connectionID;
function ADOPDOStatement($stmt,$connection)
{
$this->_stmt = $stmt;
$this->_connectionID = $connection;
}
function Execute($inputArr=false)
{
$savestmt = $this->_connectionID->_stmt;
$rs = $this->_connectionID->Execute(array(false,$this->_stmt),$inputArr);
$this->_connectionID->_stmt = $savestmt;
return $rs;
}
function InParameter(&$var,$name,$maxLen=4000,$type=false)
{
if ($type) $this->_stmt->bindParam($name,$var,$type,$maxLen);
else $this->_stmt->bindParam($name, $var);
}
function Affected_Rows()
{
return ($this->_stmt) ? $this->_stmt->rowCount() : 0;
}
function ErrorMsg()
{
if ($this->_stmt) $arr = $this->_stmt->errorInfo();
else $arr = $this->_connectionID->errorInfo();
print_r($arr);
if ($arr) {
if ($arr[0]) return $arr[2];
else return '';
} else return '-1';
}
function ErrorNo()
{
if ($this->_stmt) return $this->_stmt->errorCode();
else return $this->_connectionID->errorInfo();
}
}
/*--------------------------------------------------------------------------------------
Class Name: Recordset
--------------------------------------------------------------------------------------*/
class ADORecordSet_pdo extends ADORecordSet {
var $bind = false;
var $databaseType = "pdo";
var $dataProvider = "pdo";
function ADORecordSet_pdo($id,$mode=false)
{
if ($mode === false) {
global $ADODB_FETCH_MODE;
$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;
}
$this->fetchMode = $mode;
$this->_queryID = $id;
$this->ADORecordSet($id);
}
// returns the field object
function &FetchField($fieldOffset = -1)
{
$off=$fieldOffset+1; // offsets begin at 1
$o= new ADOFieldObject();
$o->name = @odbc_field_name($this->_queryID,$off);
$o->type = @odbc_field_type($this->_queryID,$off);
$o->max_length = @odbc_field_len($this->_queryID,$off);
if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name);
else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name);
return $o;
}
function Init()
{
if ($this->_inited) return;
$this->_inited = true;
if ($this->_queryID) @$this->_initrs();
else {
$this->_numOfRows = 0;
$this->_numOfFields = 0;
}
if ($this->_numOfRows != 0 && $this->_currentRow == -1) {
$this->_currentRow = 0;
if ($this->EOF = ($this->_fetch() === false)) {
$this->_numOfRows = 0; // _numOfRows could be -1
}
$this->_numOfFields = sizeof($this->fields);
} else {
$this->EOF = true;
}
}
function _initrs()
{
global $ADODB_COUNTRECS;
$this->_numOfRows = ($ADODB_COUNTRECS) ? @$this->_queryID->rowCount() : -1;
if (!$this->_numOfRows) $this->_numOfRows = -1;
$this->_numOfFields =0;
}
function _seek($row)
{
return false;
}
function _fetch()
{
$this->fields = $this->_queryID->fetch($this->fetchMode);
return !empty($this->fields);
}
function _close()
{
$this->_queryID = false;
}
}
?>

View File

@ -1,6 +1,6 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.

View File

@ -1,6 +1,6 @@
<?php
/*
V4.20 22 Feb 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -42,6 +42,9 @@
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
function adodb_addslashes($s)
{
$len = strlen($s);
@ -58,7 +61,10 @@ class ADODB_postgres64 extends ADOConnection{
var $_resultid = false;
var $concat_operator='||';
var $metaDatabasesSQL = "select datname from pg_database where datname not in ('template0','template1') order by 1";
var $metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%' union
var $metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%'
and tablename not in ('sql_features', 'sql_implementation_info', 'sql_languages',
'sql_packages', 'sql_sizing', 'sql_sizing_profiles')
union
select viewname,'V' from pg_views where viewname not like 'pg\_%'";
//"select tablename from pg_tables where tablename not like 'pg_%' order by 1";
var $isoDates = true; // accepts dates in ISO format
@ -434,7 +440,7 @@ select viewname,'V' from pg_views where viewname like $mask";
while (!$rsdef->EOF) {
$num = $rsdef->fields['num'];
$s = $rsdef->fields['def'];
if (substr($s, 0, 1) == "'") { /* quoted strings hack... for now... fixme */
if (strpos($s,'::')===false && substr($s, 0, 1) == "'") { /* quoted strings hack... for now... fixme */
$s = substr($s, 1);
$s = substr($s, 0, strlen($s) - 1);
}
@ -503,14 +509,14 @@ FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_index i ON i.indexrelid=c.oid
JOIN pg_catalog.pg_class c2 ON c2.oid=i.indrelid
,pg_namespace n
WHERE c2.relname=\'%s\' and c.relnamespace=c2.relnamespace and c.relnamespace=n.oid and n.nspname=\'%s\' AND i.indisprimary=false';
WHERE (c2.relname=\'%s\' or c2.relname=lower(\'%s\')) and c.relnamespace=c2.relnamespace and c.relnamespace=n.oid and n.nspname=\'%s\' AND i.indisprimary=false';
} else {
$sql = '
SELECT c.relname as "Name", i.indisunique as "Unique", i.indkey as "Columns"
FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_index i ON i.indexrelid=c.oid
JOIN pg_catalog.pg_class c2 ON c2.oid=i.indrelid
WHERE c2.relname=\'%s\'';
WHERE c2.relname=\'%s\' or c2.relname=lower(\'%s\')';
}
if ($primary == FALSE) {
@ -523,8 +529,7 @@ WHERE c2.relname=\'%s\'';
$savem = $this->SetFetchMode(FALSE);
}
$rs = $this->Execute(sprintf($sql,$table,$schema));
$rs = $this->Execute(sprintf($sql,$table,$table,$schema));
if (isset($savem)) {
$this->SetFetchMode($savem);
}
@ -534,12 +539,10 @@ WHERE c2.relname=\'%s\'';
return FALSE;
}
$col_names = $this->MetaColumnNames($table);
$col_names = $this->MetaColumnNames($table,true);
$indexes = array();
while ($row = $rs->FetchRow()) {
$columns = array();
foreach (explode(' ', $row[2]) as $col) {
$columns[] = $col_names[$col - 1];
}
@ -549,7 +552,6 @@ WHERE c2.relname=\'%s\'';
'columns' => $columns
);
}
return $indexes;
}
@ -561,7 +563,7 @@ WHERE c2.relname=\'%s\'';
function _connect($str,$user='',$pwd='',$db='',$ctype=0)
{
if (!function_exists('pg_pconnect')) return false;
if (!function_exists('pg_pconnect')) return null;
$this->_errorMsg = false;
@ -720,7 +722,10 @@ WHERE c2.relname=\'%s\'';
function ErrorNo()
{
$e = $this->ErrorMsg();
return strlen($e) ? $e : 0;
if (strlen($e)) {
return ADOConnection::MetaError($e);
}
return 0;
}
// returns true or false
@ -791,14 +796,15 @@ class ADORecordSet_postgres64 extends ADORecordSet{
function _initrs()
{
global $ADODB_COUNTRECS;
$this->_numOfRows = ($ADODB_COUNTRECS)? @pg_numrows($this->_queryID):-1;
$this->_numOfFields = @pg_numfields($this->_queryID);
$qid = $this->_queryID;
$this->_numOfRows = ($ADODB_COUNTRECS)? @pg_numrows($qid):-1;
$this->_numOfFields = @pg_numfields($qid);
// cache types for blob decode check
for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) {
$f1 = $this->FetchField($i);
//print_r($f1);
if ($f1->type == 'bytea') $this->_blobArr[$i] = $f1->name;
if (pg_fieldtype($qid,$i) == 'bytea') {
$this->_blobArr[$i] = pg_fieldname($qid,$off);
}
}
}
@ -817,16 +823,14 @@ class ADORecordSet_postgres64 extends ADORecordSet{
return $this->fields[$this->bind[strtoupper($colname)]];
}
function &FetchField($fieldOffset = 0)
function &FetchField($off = 0)
{
$off=$fieldOffset; // offsets begin at 0
// offsets begin at 0
$o= new ADOFieldObject();
$o->name = @pg_fieldname($this->_queryID,$off);
$o->type = @pg_fieldtype($this->_queryID,$off);
$o->max_length = @pg_fieldsize($this->_queryID,$off);
//print_r($o);
//print "off=$off name=$o->name type=$o->type len=$o->max_length<br>";
return $o;
}

View File

@ -1,6 +1,6 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -11,6 +11,9 @@
01 Dec 2001: dannym added support for default values
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
include_once(ADODB_DIR."/drivers/adodb-postgres64.inc.php");
class ADODB_postgres7 extends ADODB_postgres64 {

View File

@ -1,6 +1,6 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -9,6 +9,9 @@ V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights rese
Synonym for csv driver.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
if (! defined("_ADODB_PROXY_LAYER")) {
define("_ADODB_PROXY_LAYER", 1 );
include(ADODB_DIR."/drivers/adodb-csv.inc.php");

View File

@ -1,17 +1,20 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
SAPDB data driver. Requires ODBC.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
if (!defined('_ADODB_ODBC_LAYER')) {
include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
}

View File

@ -1,13 +1,13 @@
<?php
/*
version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights
version V4.50 6 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 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
21.02.2002 - Wade Johnson wade@wadejohnson.de
Extended ODBC class for Sybase SQLAnywhere.
@ -41,6 +41,9 @@ Set tabs to 4 for best viewing.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
if (!defined('_ADODB_ODBC_LAYER')) {
include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
}

View File

@ -1,11 +1,11 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
SQLite info: http://www.hwaci.com/sw/sqlite/
@ -15,6 +15,9 @@ V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights rese
2. Rename the file, remove the .txt prefix.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB_sqlite extends ADOConnection {
var $databaseType = "sqlite";
var $replaceQuote = "''"; // string to use to replace quotes
@ -127,7 +130,7 @@ class ADODB_sqlite extends ADOConnection {
// returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if (!function_exists('sqlite_open')) return false;
if (!function_exists('sqlite_open')) return null;
$this->_connectionID = sqlite_open($argHostname);
if ($this->_connectionID === false) return false;
@ -138,7 +141,7 @@ class ADODB_sqlite extends ADOConnection {
// returns true or false
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if (!function_exists('sqlite_open')) return false;
if (!function_exists('sqlite_open')) return null;
$this->_connectionID = sqlite_popen($argHostname);
if ($this->_connectionID === false) return false;

View File

@ -0,0 +1,62 @@
<?php
/*
V4.50 6 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.
Portable version of sqlite driver, to make it more similar to other database drivers.
The main differences are
1. When selecting (joining) multiple tables, in assoc mode the table
names are included in the assoc keys in the "sqlite" driver.
In "sqlitepo" driver, the table names are stripped from the returned column names.
When this results in a conflict, the first field get preference.
Contributed by Herman Kuiper herman#ozuzo.net
*/
if (!defined('ADODB_DIR')) die();
include_once(ADODB_DIR.'/drivers/adodb-sqlite.inc.php');
class ADODB_sqlitepo extends ADODB_sqlite {
var $databaseType = 'sqlitepo';
function ADODB_sqlitepo()
{
$this->ADODB_sqlite();
}
}
/*--------------------------------------------------------------------------------------
Class Name: Recordset
--------------------------------------------------------------------------------------*/
class ADORecordset_sqlitepo extends ADORecordset_sqlite {
var $databaseType = 'sqlitepo';
function ADORecordset_sqlitepo($queryID,$mode=false)
{
$this->ADORecordset_sqlite($queryID,$mode);
}
// Modified to strip table names from returned fields
function _fetch($ignore_fields=false)
{
$this->fields = array();
$fields = @sqlite_fetch_array($this->_queryID,$this->fetchMode);
if(is_array($fields))
foreach($fields as $n => $v)
{
if(($p = strpos($n, ".")) !== false)
$n = substr($n, $p+1);
$this->fields[$n] = $v;
}
return !empty($this->fields);
}
}
?>

View File

@ -1,12 +1,12 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim. All rights reserved.
V4.50 6 July 2004 (c) 2000-2004 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.
Set tabs to 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Sybase driver contributed by Toni (toni.tunkkari@finebyte.com)
@ -15,6 +15,9 @@ V4.22 15 Apr 2004 (c) 2000-2004 John Lim. All rights reserved.
Date patch by Toni 15 Feb 2002
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB_sybase extends ADOConnection {
var $databaseType = "sybase";
//var $dataProvider = 'sybase';
@ -112,7 +115,7 @@ class ADODB_sybase extends ADOConnection {
// returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if (!function_exists('sybase_connect')) return false;
if (!function_exists('sybase_connect')) return null;
$this->_connectionID = sybase_connect($argHostname,$argUsername,$argPassword);
if ($this->_connectionID === false) return false;
@ -122,7 +125,7 @@ class ADODB_sybase extends ADOConnection {
// returns true or false
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if (!function_exists('sybase_connect')) return false;
if (!function_exists('sybase_connect')) return null;
$this->_connectionID = sybase_pconnect($argHostname,$argUsername,$argPassword);
if ($this->_connectionID === false) return false;

View File

@ -1,16 +1,19 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Microsoft Visual FoxPro data driver. Requires ODBC. Works only on MS Windows.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
if (!defined('_ADODB_ODBC_LAYER')) {
include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
}

View File

@ -0,0 +1,36 @@
<?php
// Contributed by Grzegorz Pacan <gp#dione.cc>
$ADODB_LANG_ARRAY = array (
'LANG' => 'pl',
DB_ERROR => 'niezidentyfikowany błąd',
DB_ERROR_ALREADY_EXISTS => 'już istnieją',
DB_ERROR_CANNOT_CREATE => 'nie można stworzyć',
DB_ERROR_CANNOT_DELETE => 'nie można usunąć',
DB_ERROR_CANNOT_DROP => 'nie można porzucić',
DB_ERROR_CONSTRAINT => 'pogwałcenie uprawnień',
DB_ERROR_DIVZERO => 'dzielenie przez zero',
DB_ERROR_INVALID => 'błędny',
DB_ERROR_INVALID_DATE => 'błędna godzina lub data',
DB_ERROR_INVALID_NUMBER => 'błędny numer',
DB_ERROR_MISMATCH => 'niedopasowanie',
DB_ERROR_NODBSELECTED => 'baza danych nie została wybrana',
DB_ERROR_NOSUCHFIELD => 'nie znaleziono pola',
DB_ERROR_NOSUCHTABLE => 'nie znaleziono tabeli',
DB_ERROR_NOT_CAPABLE => 'nie zdolny',
DB_ERROR_NOT_FOUND => 'nie znaleziono',
DB_ERROR_NOT_LOCKED => 'nie zakmnięty',
DB_ERROR_SYNTAX => 'błąd składni',
DB_ERROR_UNSUPPORTED => 'nie obsługuje',
DB_ERROR_VALUE_COUNT_ON_ROW => 'wartość liczona w szeregu',
DB_ERROR_INVALID_DSN => 'błędny DSN',
DB_ERROR_CONNECT_FAILED => 'połączenie nie zostało zrealizowane',
0 => 'brak błędów', // DB_OK
DB_ERROR_NEED_MORE_DATA => 'niedostateczna ilość informacji',
DB_ERROR_EXTENSION_NOT_FOUND=> 'nie znaleziono rozszerzenia',
DB_ERROR_NOSUCHDB => 'nie znaleziono bazy',
DB_ERROR_ACCESS_VIOLATION => 'niedostateczne uprawnienia'
);
?>

View File

@ -2,12 +2,12 @@ ADOdb is dual licensed using BSD and LGPL.
In plain English, you do not need to distribute your application in source code form, nor do you need to distribute ADOdb source code, provided you follow the rest of terms of the BSD license.
Commercial use of ADOdb is encouraged. Make money and multiply!
For more info about ADOdb, visit http://adodb.sourceforge.net/
BSD Style-License
=================
Copyright (c) 2000, 2001, 2002, 2003 John Lim
Copyright (c) 2000, 2001, 2002, 2003, 2004 John Lim
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,

View File

@ -0,0 +1,436 @@
<?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 |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Martin Jansen <mj@php.net>
// | Richard Tango-Lowy <richtl@arscognita.com> |
// +----------------------------------------------------------------------+
//
// $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;
$this->_parseDsn( $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($this->options['db_type']);
if( $err = ADODB_Pear_error() ) {
return PEAR::raiseError($err);
}
}
$dbconnected = $this->db->Connect(
$this->options['db_host'],
$this->options['db_user'],
$this->options['db_pass'],
$this->options['db_name'] );
if( !$dbconnected ) {
PEAR::raiseError('Unable to connect to database' );
}
} 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 _parseDsn( $dsn )
{
if( is_string( $dsn )) {
preg_match( '/^(\w*):\/\/(\w*)(:(\w*))?@(\w*)\/(\w*)$/', $dsn, $match );
$this->options['db_type'] = $match[1];
$this->options['db_user'] = $match[2];
$this->options['db_pass'] = $match[3];
$this->options['db_host'] = $match[5];
$this->options['db_name'] = $match[6];
}
}
}
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>";
}
?>

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

View File

@ -1,17 +1,19 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Library for basic performance monitoring and tuning
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
// Simple guide to configuring db2: so-so http://www.devx.com/gethelpon/10MinuteSolution/16575

View File

@ -1,17 +1,20 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Library for basic performance monitoring and tuning
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
//
// Thx to Fernando Ortiz, mailto:fortiz#lacorona.com.mx
// With info taken from http://www.oninit.com/oninit/sysmaster/index.html

View File

@ -1,18 +1,21 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Library for basic performance monitoring and tuning
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
/*
MSSQL has moved most performance info to Performance Monitor
*/

View File

@ -1,17 +1,20 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Library for basic performance monitoring and tuning
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class perf_mysql extends adodb_perf{
var $tablesSQL = 'show table status';

View File

@ -1,17 +1,20 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Library for basic performance monitoring and tuning
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class perf_oci8 extends ADODB_perf{
var $tablesSQL = "select segment_name as \"tablename\", sum(bytes)/1024 as \"size_in_k\",tablespace_name as \"tablespace\",count(*) \"extents\" from sys.user_extents
@ -78,7 +81,7 @@ AND b.name = 'sorts (memory)'",
'db_cache_size' ),
'shared pool size' => array('DATAC',
"select value from v\$parameter where name = 'shared_pool_size'",
'shared_pool_size, which holds shared cursors, stored procedures and similar shared structs' ),
'shared_pool_size, which holds shared sql, stored procedures, dict cache and similar shared structs' ),
'java pool size' => array('DATAJ',
"select value from v\$parameter where name = 'java_pool_size'",
'java_pool_size' ),
@ -104,7 +107,7 @@ AND b.name = 'sorts (memory)'",
"select round((1-bytes/sgasize)*100, 2)
from (select sum(bytes) sgasize from sys.v_\$sgastat) s, sys.v_\$sgastat f
where name = 'free memory' and pool = 'shared pool'",
'Percentage of data cache actually in use - too low is bad, too high is worse'),
'Percentage of data cache actually in use - should be over 85%'),
'shared pool utilization ratio' => array('RATIOU',
'select round((sga.bytes/p.value)*100,2)
@ -120,7 +123,7 @@ AND b.name = 'sorts (memory)'",
'Percentage of large_pool actually in use - too low is bad, too high is worse'),
'sort buffer size' => array('CACHE',
"select value from v\$parameter where name='sort_area_size'",
'sort_area_size (per query), uses memory in pga' ),
'max in-mem sort_area_size (per query), uses memory in pga' ),
'pga usage at peak' => array('RATIOU',
'=PGA','Mb utilization at peak transactions (requires Oracle 9i+)'),
@ -141,7 +144,12 @@ AND b.name = 'sorts (memory)'",
'cursor sharing' => array('CURSOR',
"select value from v\$parameter where name = 'cursor_sharing'",
'Cursor reuse strategy. Recommended is FORCE (8i+) or SIMILAR (9i+). See <a href=http://www.praetoriate.com/oracle_tips_cursor_sharing.htm>cursor_sharing</a>.'),
/*
'cursor reuse' => array('CURSOR',
"select count(*) from (select sql_text_wo_constants, count(*)
from t1
group by sql_text_wo_constants
having count(*) > 100)",'These are sql statements that should be using bind variables'),*/
'index cache cost' => array('COST',
"select value from v\$parameter where name = 'optimizer_index_caching'",
'% of indexed data blocks expected in the cache.

View File

@ -1,18 +1,21 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
Library for basic performance monitoring and tuning
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
/*
Notice that PostgreSQL has no sql query cache
*/

View File

@ -1,6 +1,6 @@
<?php
/**
* @version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
* @version V4.50 6 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.

View File

@ -1,6 +1,6 @@
<?php
/**
* @version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
* @version V4.50 6 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.

View File

@ -1,7 +1,7 @@
<?php
/**
* @version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
* @version V4.50 6 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.

View File

@ -12,6 +12,9 @@ V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights rese
*/
// security - hide paths
if (!defined('ADODB_SESSION')) die();
include_once ADODB_SESSION . '/crypt.inc.php';
/**

View File

@ -681,8 +681,8 @@ class ADODB_Session {
if (!$rs->EOF) {
$ref = $rs->fields[0];
$key = $rs->fields[1];
assert('$ref');
assert('$key');
//assert('$ref');
//assert('$key');
$fn($ref, $key);
}
$rs->Close();

View File

@ -1,6 +1,6 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.

View File

@ -1,6 +1,6 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.

View File

@ -1,6 +1,6 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.

View File

@ -8,7 +8,7 @@
<body>
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.

View File

@ -2,7 +2,7 @@
<body bgcolor=white>
<?php
/**
* V4.22 15 Apr 2004 (c) 2001-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
* V4.50 6 July 2004 (c) 2001-2002 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.

View File

@ -0,0 +1,42 @@
<?php
error_reporting(E_ALL);
include('../adodb.inc.php');
echo "New Connection\n";
$DB = NewADOConnection('pdo');
echo "Connect\n";
$pdo_connection_string = 'odbc:nwind';
$DB->Connect($pdo_connection_string,'','') || die("CONNECT FAILED");
echo "Execute\n";
//$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$rs = $DB->Execute("select * from products where productid<3");
echo "e=".$DB->ErrorNo() . " ".($DB->ErrorMsg())."\n";
//print_r(get_class_methods($DB->_stmt));
if (!$rs) die("NO RS");
echo "FETCH\n";
$cnt = 0;
while (!$rs->EOF) {
print_r($rs->fields);
$rs->MoveNext();
if ($cnt++ > 1000) break;
}
echo "<br>--------------------------------------------------------<br>\n\n\n";
$stmt = $DB->PrepareStmt("select * from products");
$rs = $stmt->Execute();
echo "e=".$stmt->ErrorNo() . " ".($stmt->ErrorMsg())."\n";
while ($arr = $rs->FetchRow()) {
print_r($arr);
}
die("DONE\n");
?>

View File

@ -1,7 +1,7 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -13,7 +13,7 @@
error_reporting(E_ALL);
include_once('../adodb.inc.php');
foreach(array('sybase','mysql','access','oci8','postgres','odbc_mssql','odbc','sybase','firebird','informix','db2') as $dbType) {
foreach(array('sybase','mysqlt','access','oci8','postgres','odbc_mssql','odbc','sybase','firebird','informix','db2') as $dbType) {
echo "<h3>$dbType</h3><p>";
$db = NewADOConnection($dbType);
$dict = NewDataDictionary($db);
@ -21,7 +21,7 @@ foreach(array('sybase','mysql','access','oci8','postgres','odbc_mssql','odbc','s
if (!$dict) continue;
$dict->debug = 1;
$opts = array('REPLACE','mysql' => 'TYPE=ISAM', 'oci8' => 'TABLESPACE USERS');
$opts = array('REPLACE','mysql' => 'TYPE=INNODB', 'oci8' => 'TABLESPACE USERS');
/* $flds = array(
array('id', 'I',

View File

@ -1,6 +1,6 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -18,7 +18,7 @@ include("$path/../adodb.inc.php");
echo "<h3>PHP ".PHP_VERSION."</h3>\n";
try {
$dbt = 'oci8';
$dbt = 'mysqli';
switch($dbt) {
case 'oci8':
@ -30,6 +30,11 @@ case 'mysql':
$db = NewADOConnection("mysql");
$db->Connect('localhost','root','','test');
break;
case 'mysqli':
$db = NewADOConnection("mysqli");
$db->Connect('localhost','root','','test');
break;
}
$db->debug=1;

View File

@ -1,6 +1,6 @@
<?PHP
// V4.22 15 Apr 2004
// V4.50 6 July 2004
error_reporting(E_ALL);
@ -31,4 +31,21 @@ print "</pre>\n";
// Finally, clean up after the XML parser
// (PHP won't do this for you!)
//$schema->Destroy();
$db2 = ADONewConnection('mssql');
$db2->Connect('localhost','sa','natsoft','northwind') || die("Fail 2");
$db2->Execute("drop table simple_table");
$schema = new adoSchema( $db2 );
$sql = $schema->ParseSchema( "xmlschema-mssql.xml" );
print "Here's the SQL to do the build:\n<pre>";
print_r( $sql );
print "</pre>\n";
$db2->debug=1;
$db2->Execute($sql[0]);
?>

View File

@ -1,12 +1,12 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
*/
error_reporting(E_ALL);
@ -82,6 +82,7 @@ GLOBAL $ADODB_vers,$ADODB_CACHE_DIR,$ADODB_FETCH_MODE, $HTTP_GET_VARS,$ADODB_COU
$EXECS = 0;
$CACHED = 0;
//$db->Execute("drop table adodb_logsql");
if ((rand()%3) == 0) @$db->Execute("delete from adodb_logsql");
$db->debug=1;
@ -122,8 +123,7 @@ FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_to
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'");
@ -254,7 +254,7 @@ FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_to
}
$a = $db->MetaTables('VIEW');
if ($a===false) print "<b>MetaTables not supported</b></p>";
if ($a===false) print "<b>MetaTables not supported (views)</b></p>";
else {
print "Array of views: ";
foreach($a as $v) print " ($v) ";
@ -262,7 +262,7 @@ FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_to
}
$a = $db->MetaTables(false,false,'aDo%');
if ($a===false) print "<b>MetaTables not supported</b></p>";
if ($a===false) print "<b>MetaTables not supported (mask)</b></p>";
else {
print "Array of ado%: ";
foreach($a as $v) print " ($v) ";
@ -287,11 +287,12 @@ FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_to
}
print "<p>Testing MetaIndexes</p>";
$a = $db->MetaIndexes('ADOXYZ',true);
$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>";
foreach($a as $v) {print_r($v); echo "<br>";}
adodb_pr($a);
echo "</font>";
}
print "<p>Testing MetaPrimaryKeys</p>";
@ -375,7 +376,7 @@ GO
rs2html($rs);
/*
Test out params - works in 4.2.3 but not 4.3.0???:
Test out params - works in 4.2.3 and 4.3.3 but not 4.3.0:
CREATE PROCEDURE at_date_interval
@days INTEGER,
@ -585,6 +586,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";
$db->debug = false;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
@ -612,7 +622,7 @@ END adodb;
}
if (empty($HTTP_GET_VARS['hide'])) rs2html($rs);
}
else print "<b>Error in Execute of SELECT with random</b></p>";
else print "<p><b>Error in Execute of SELECT with random</b></p>";
}
$val = $db->GetOne("select count(*) from ADOXYZ");
if ($val == 50) print "<p>GetOne returns ok</p>";
@ -679,10 +689,17 @@ END adodb;
print "<p>FETCH_MODE = ASSOC: Should get 1, Caroline</p>";
$rs = &$db->SelectLimit('select id,firstname from ADOXYZ order by id',2);
if ($rs && !$rs->EOF) {
if ($rs->fields['id'] != 1) {Err("Error 1"); print_r($rs->fields);};
if (trim($rs->fields['firstname']) != 'Caroline') {Err("Error 2"); print_r($rs->fields);};
if (ADODB_ASSOC_CASE == 2) {
$id = 'ID';
$fname = 'FIRSTNAME';
}else {
$id = 'id';
$fname = 'firstname';
}
if ($rs->fields[$id] != 1) {Err("Error 1"); print_r($rs->fields);};
if (trim($rs->fields[$fname]) != 'Caroline') {Err("Error 2"); print_r($rs->fields);};
$rs->MoveNext();
if ($rs->fields['id'] != 2) {Err("Error 3"); print_r($rs->fields);};
if ($rs->fields[$id] != 2) {Err("Error 3"); print_r($rs->fields);};
$rs->MoveNext();
if (!$rs->EOF) Err("Error EOF");
else if (is_array($rs->fields) || $rs->fields) {
@ -884,18 +901,22 @@ END adodb;
print "Testing GetAssoc() ";
$savecrecs = $ADODB_COUNTRECS;
$ADODB_COUNTRECS = false;
$rs = &$db->Execute("select distinct lastname,firstname from ADOXYZ");
//$arr = $db->GetArray("select lastname,firstname from ADOXYZ");
//print_r($arr);
print "<hr>";
$rs =& $db->Execute("select distinct lastname,firstname from ADOXYZ");
if ($rs) {
$arr = $rs->GetAssoc();
//print_r($arr);
if (trim($arr['See']) != 'Wai Hun') print $arr['See']." &nbsp; <b>ERROR</b><br>";
if (empty($arr['See']) || trim($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 (trim($arr['See']) != 'Wai Hun') print $arr['See']." &nbsp; <b>ERROR</b><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
@ -1083,10 +1104,11 @@ END adodb;
$rs = $db->SelectLimit('select id,firstname,lastname,created,\'The "young man", he said\' from adoxyz',10);
if (PHP_VERSION < 5) {
print "<pre>";
rs2tabout($rs);
print "</pre>";
}
//print " CacheFlush ";
//$db->CacheFlush();
@ -1248,7 +1270,7 @@ END adodb;
if (!$date) Err("Bad sysDate");
else {
$ds = $db->UserDate($date,"d m Y");
if ($ds != date("d m Y")) Err("Bad UserDate: ".$ds);
if ($ds != date("d m Y")) Err("Bad UserDate: ".$ds.' expected='.date("d m Y"));
else echo "Passed UserDate: $ds<p>";
}
$db->debug=1;
@ -1356,7 +1378,7 @@ END adodb;
$conn = NewADOConnection($db->databaseType);
$conn->raiseErrorFn = 'adodb_test_err';
@$conn->Connect('abc');
@$conn->PConnect('abc');
if ($TESTERRS == 2) print "raiseErrorFn tests passed<br>";
else print "<b>raiseErrorFn tests failed ($TESTERRS)</b><br>";
@ -1398,7 +1420,7 @@ global $TESTERRS,$ERRNO;
//--------------------------------------------------------------------------------------
set_time_limit(240); // increase timeout
@set_time_limit(240); // increase timeout
include("../tohtml.inc.php");
include("../adodb.inc.php");
@ -1418,7 +1440,7 @@ if ( @$HTTP_SERVER_VARS['COMPUTERNAME'] == 'TIGRESS') {
CheckWS('firebird');
CheckWS('sybase');
CheckWS('informix');
if (!ini_get('safe_mode')) CheckWS('informix');
CheckWS('ado_mssql');
CheckWS('ado_access');
@ -1429,6 +1451,7 @@ if ( @$HTTP_SERVER_VARS['COMPUTERNAME'] == 'TIGRESS') {
CheckWS('db2');
CheckWS('access');
CheckWS('odbc_mssql');
CheckWS('firebird15');
//
CheckWS('oracle');
CheckWS('proxy');
@ -1463,9 +1486,8 @@ Test <a href=test4.php>GetInsertSQL/GetUpdateSQL</a> &nbsp;
<a href=test-perf.php>Perf Monitor</a><p>
<?php
include('./testdatabases.inc.php');
?>
<?php
echo "<br>vers=",ADOConnection::Version();
include_once('../adodb-time.inc.php');
adodb_date_test();

View File

@ -8,7 +8,7 @@
<body>
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.

View File

@ -1,6 +1,6 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.

View File

@ -1,7 +1,7 @@
<?php
/**
* @version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
* @version V4.50 6 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.

View File

@ -1,12 +1,12 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
*/

View File

@ -2,13 +2,13 @@
<body>
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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 4 for best viewing.
Latest version is available at http://php.weblogs.com/
Latest version is available at http://adodb.sourceforge.net
*/
$ADODB_CACHE_DIR = dirname(tempnam('/tmp',''));

View File

@ -1,7 +1,7 @@
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.50 6 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.
@ -47,6 +47,7 @@ if (!strpos(PHP_VERSION,'5') === 0) {
ADOLoadCode("borland_ibase");
ADOLoadCode("informix");
ADOLoadCode("sqlanywhere");
// ADOLoadCode('mysqli');
}
@ -76,7 +77,7 @@ if (!empty($testpgodbc)) {
}
if (!empty($testibase)) {
//$_GET['nolog'] = true;
$db = &ADONewConnection('firebird');
print "<h1>Connecting $db->databaseType...</h1>";
if (@$db->PConnect("localhost:d:\\firebird\\10\\examples\\employee.gdb", "sysdba", "masterkey", ""))
@ -151,6 +152,21 @@ if (!empty($testmysql)) { // MYSQL
} else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg();
}
// REQUIRES MySQL server at localhost with database 'test'
if (!empty($testmysqli)) { // MYSQL
$db = &ADONewConnection('mysqli');
print "<h1>Connecting $db->databaseType...</h1>";
if (PHP_VERSION >= 5 || $HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost';
else $server = "mangrove";
if ($db->PConnect($server, "root", "", "northwind")) {
//$db->debug=1;$db->Execute('drop table ADOXYZ');
testdb($db,
"create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)");
} else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg();
}
// REQUIRES MySQL server at localhost with database 'test'
if (!empty($testmysqlodbc)) { // MYSQL

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