Upgraded to ADOdb 2.12

This commit is contained in:
martin 2002-06-13 12:31:58 +00:00
parent 22f4320bdb
commit b1a1b00aa6
58 changed files with 1259 additions and 369 deletions

View file

@ -8,7 +8,7 @@
<body>
<?php
/*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
V2.12 12 June 2002 (c) 2000-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

@ -2,7 +2,7 @@
<body bgcolor=white>
<?php
/**
* (c)2001,2002 John Lim (jlim@natsoft.com.my). All rights reserved.
* V2.12 12 June 2002 (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

@ -1,7 +1,7 @@
<?php
/*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
V2.12 12 June 2002 (c) 2000-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.
@ -86,8 +86,8 @@ GLOBAL $ADODB_vers,$ADODB_CACHE_DIR,$ADODB_FETCH_MODE, $HTTP_GET_VARS,$ADODB_COU
print "<h3>ADODB Version: $ADODB_vers Host: <i>$db->host</i> &nbsp; Database: <i>$db->database</i> &nbsp; PHP: $phpv</h3>";
$e = error_reporting(E_ALL-E_WARNING);
print "<i>date1</i> (1999-02-20) = ".$db->DBDate('1999-2-20');
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>date2</i> (1970-1-2) = ".$db->DBDate(24*3600)."<p>";
print "<i>ts1</i> (1999-02-20 3:40:50) = ".$db->DBTimeStamp('1999-2-20 3:40:50');
print "<br><i>ts2</i> (1999-02-20) = ".$db->DBTimeStamp('1999-2-20');
@ -140,12 +140,13 @@ GLOBAL $ADODB_vers,$ADODB_CACHE_DIR,$ADODB_FETCH_MODE, $HTTP_GET_VARS,$ADODB_COU
if ($rs) $rs->Close();
$db->debug=false;
//$db->debug=true;
print "<p>Testing Commit: ";
$time = $db->DBDate(time());
if (!$db->BeginTrans()) print '<b>Transactions not supported</b></p>';
else { /* COMMIT */
$rs = $db->Execute("insert into ADOXYZ values (99,'Should Not','Exist (Commit)',$time)");
$rs = $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values (99,'Should Not','Exist (Commit)',$time)");
if ($rs && $db->CommitTrans()) {
$rs->Close();
$rs = &$db->Execute("select * from ADOXYZ where id=99");
@ -156,13 +157,16 @@ GLOBAL $ADODB_vers,$ADODB_CACHE_DIR,$ADODB_FETCH_MODE, $HTTP_GET_VARS,$ADODB_COU
die();
} else print 'OK</p>';
if ($rs) $rs->Close();
} else
print "<b>Commit failed</b></p>";
} else {
if (!$rs) {
print "<b>Insert failed</b></p>";
$db->RollbackTrans();
} else print "<b>Commit failed</b></p>";
}
/* ROLLBACK */
if (!$db->BeginTrans()) print "<p><b>Error in BeginTrans</b>()</p>";
print "<p>Testing Rollback: ";
$db->Execute("insert into ADOXYZ values (100,'Should Not','Exist (Rollback)',$time)");
$db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values (100,'Should Not','Exist (Rollback)',$time)");
if ($db->RollbackTrans()) {
$rs = $db->Execute("select * from ADOXYZ where id=100");
if ($rs && !$rs->EOF) print '<b>Fail: Data should rollback</b></p>';
@ -307,11 +311,10 @@ GO
$db->debug = false;
$ADODB_FETCH_MODE = ADODB_FETCH_BOTH;
///////////////////////////////
$rs = &$db->Execute("select * from ADOXYZ order by id");
//////////////////////////////////////////////////////////////////////////////////////////
$rs = &$db->Execute("select id,firstname as TheFirstName,lastname,created from ADOXYZ order by id");
if ($rs) {
// print_r($rs);
if ($rs->RecordCount() != 50) {
print "<p><b>RecordCount returns -1</b></p>";
if ($rs->PO_RecordCount('ADOXYZ') == 50) print "<p> &nbsp; &nbsp; PO_RecordCount passed</p>";
@ -586,7 +589,7 @@ GO
if ($val == 0) echo " <p><b>GenID not supported</b>";
echo "<p>";
if (substr($db->dataProvider,0,3) != 'ado') { // crashes ado
if (substr($db->dataProvider,0,3) != 'notused') { // used to crash ado
$sql = "select firstnames from adoxyz";
print "<p>Testing execution of illegal statement: <i>$sql</i></p>";
if ($db->Execute($sql) === false) {
@ -655,7 +658,9 @@ GO
print "<p><b>Invalid date {$rs->fields[0]}</b></p>";
} else
print "<p>Passed \$sysDate test ({$rs->fields[0]})</p>";
print_r($rs->FetchField(0));
print time();
$db->debug=$saved;
} else {
print "<p><b>\$db->sysDate not defined</b></p>";
@ -678,10 +683,44 @@ GO
}
$rs->Close();
}
print "<p>Test CSV</p>";
include_once('../toexport.inc.php');
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$rs = $db->SelectLimit('select id,firstname,lastname,created,\'The "young man", he said\' from adoxyz',10);
print "<pre>";
print rs2csv($rs);
print "</pre>";
$rs = $db->SelectLimit('select id,firstname,lastname,created,\'The "young man", he said\' from adoxyz',10);
print "<pre>";
tab2csvout($rs);
print "</pre>";
$db->debug=1;
print "<p>Test Replace</p>";
$ret = $db->Replace('adoxyz',
array('id'=>1000,'firstname'=>'Harun','lastname'=>'Al-Rashid'),
array('id','firstname'),
$autoq = true);
if ($ret != 2) print "<b>Replace failed: </b>";
print "test A return value=$ret (2 expected) <p>";
$ret = $db->Replace('adoxyz',
array('id'=>1000,'firstname'=>'Sherazade','lastname'=>'Al-Rashid'),
'id',
$autoq = true);
if ($ret != 1) print "<b>Replace failed: </b>";
print "test B return value=$ret (1 expected) <p>";
/////////////////////////////////////////////////////////////
include_once "PEAR.php";
$db->debug =true;
if ($i != 50) {
print "<p><b>PEAR DB emulation error 1.1 EOF ($i)</b></p>";
$pear = false;
@ -713,14 +752,21 @@ GO
global $TESTERRS;
$debugerr = true;
$db->debug = false;
$TESTERRS = 0;
$db->raiseErrorFn = 'adodb_test_err';
$db->Execute('select * from nowhere');
if ($TESTERRS != 1) print "<b>raiseErrorFn select nowhere failed</b><br>";
$rs = $db->Execute('select * from adoxyz');
if ($debugerr) print " Move";
$rs->Move(100);
$rs->_queryID = false;
if ($debugerr) print " MoveNext";
$rs->MoveNext();
if ($debugerr) print " $rs=false";
$rs = false;
$conn = NewADOConnection($db->databaseType);
$conn->raiseErrorFn = 'adodb_test_err';

View file

@ -8,7 +8,7 @@
<body>
<?php
/*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
V2.12 12 June 2002 (c) 2000-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.
@ -23,30 +23,15 @@ include("../adodb.inc.php");
ADOLoadCode('mysql');
$c1 = ADONewConnection('mysql');
$c2 = ADONewConnection('mysql');
$c1 = ADONewConnection('oci8');
if (!$c1->PConnect('flipper','','',"test"))
die("Cannot connect to flipper");
if (!$c2->PConnect('mangrove','root','',"northwind"))
die("Cannot connect to mangrove");
print "<h3>Flipper</h3>";
$t = $c1->MetaTables(); # list all tables in DB
print_r($t);
# select * from last table in DB
rs2html($c1->Execute("select * from ".$t[sizeof($t)-1]));
print "<h3>Mangrove</h3>";
$t = $c2->MetaTables();
print_r($t);
rs2html($c2->Execute("select * from ".$t[sizeof($t)-1] ));
print "<h3>Flipper</h3>";
$t = $c1->MetaTables();
print_r($t);
rs2html($c1->Execute("select * from ".$t[sizeof($t)-1]));
if (!$c1->PConnect('','scott','tiger'))
die("Cannot connect to server");
$c1->debug=1;
$rs = $c1->CacheExecute(1200,'select rownum, p1.firstname,p2.lastname,p2.firstname,p1.lastname from adoxyz p1, adoxyz p2');
print "Records=".$rs->RecordCount()."<br>";
rs2html($rs);
?>

View file

@ -1,7 +1,7 @@
<code>
<?php
/*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
V2.12 12 June 2002 (c) 2000-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

@ -1,7 +1,7 @@
<?php
/**
* @version V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
* @version V2.12 12 June 2002 (c) 2000-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

@ -1,6 +1,6 @@
<?php
/*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
V2.12 12 June 2002 (c) 2000-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

@ -2,7 +2,7 @@
<body>
<?php
/*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
V2.12 12 June 2002 (c) 2000-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

@ -1,7 +1,7 @@
<?php
/*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
V2.12 12 June 2002 (c) 2000-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.
@ -106,7 +106,7 @@ ADOLoadCode('oci805');
ADOLoadCode("oci8po");
if (!empty($testoracle)) {
$db = ADONewConnection();
$db = ADONewConnection('oci8po');
print "<h1>Connecting $db->databaseType...</h1>";
if ($db->Connect('', "scott", "tiger",'natsoft.ecosystem.natsoft.com.my'))
//if ($db->PConnect("", "scott", "tiger", "juris.ecosystem.natsoft.com.my"))
@ -127,7 +127,7 @@ if (false && !empty($testoracle)) {
ADOLoadCode("odbc_mssql");
if (!empty($testmssql) and false) { // MS SQL Server via ODBC
if (!empty($testmssql) && false) { // MS SQL Server via ODBC
$db = ADONewConnection();
@ -143,10 +143,11 @@ ADOLoadCode("ado_mssql");
if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC -- DSN-less
$db = &ADONewConnection("ado_mssql");
$db->debug=1;
print "<h1>Connecting DSN-less $db->databaseType...</h1>";
$myDSN="PROVIDER=MSDASQL;DRIVER={SQL Server};"
. "SERVER=(local);DATABASE=NorthWind;UID=sa;PWD=natsoft;" ;
. "SERVER=mangrove;DATABASE=NorthWind;UID=sa;PWD=natsoft;" ;
if (@$db->PConnect($myDSN, "", "", ""))
@ -159,6 +160,7 @@ if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC
ADOLoadCode("mssql");
if (!empty($testmssql)) { // MS SQL Server -- the extension is buggy -- probably better to use ODBC
$db = ADONewConnection();
$db->debug=1;
print "<h1>Connecting $db->databaseType...</h1>";
$db->Connect('(local)\NetSDK','','','northwind');
@ -174,7 +176,7 @@ if (!empty($testmssql) && !empty($testado)) { // ADO ACCESS MSSQL with OLEDB pro
$db = &ADONewConnection("ado_mssql");
print "<h1>Connecting DSN-less OLEDB Provider $db->databaseType...</h1>";
$db->debug=1;
$myDSN="SERVER=mangrove;DATABASE=ai;";
//$myDSN='SERVER=(local)\NetSDK;DATABASE=northwind;';
if ($db->PConnect($myDSN, "sa", "natsoft", 'SQLOLEDB'))

View file

@ -1,5 +1,7 @@
<?php
/*
V2.12 12 June 2002
Run multiple copies of this php script at the same time
to test unique generation of id's in multiuser mode
*/

View file

@ -0,0 +1,50 @@
<?php
/**
* @version V2.12 12 June 2002 (c) 2000-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.
*
* Set tabs to 4 for best viewing.
*
* Latest version is available at http://php.weblogs.com
*
* Test GetUpdateSQL and GetInsertSQL.
*/
error_reporting(E_ALL);
include('../adodb.inc.php');
include('../tohtml.inc.php');
//==========================
// This code tests an insert
$conn = &ADONewConnection("odbc_mssql"); // create a connection
$conn->Connect('sqlserver','sa','natsoft');
//$conn = &ADONewConnection("mssql");
//$conn->Connect('mangrove','sa','natsoft','ai');
//$conn->Connect('mangrove','sa','natsoft','ai');
$conn->debug=1;
$conn->Execute('delete from blobtest');
$conn->Execute('insert into blobtest (id) values(1)');
$conn->UpdateBlobFile('blobtest','b1','../cute_icons_for_site/adodb.gif','id=1');
$rs = $conn->Execute('select b1 from blobtest where id=1');
$output = "c:\\temp\\test_out-".date('H-i-s').".gif";
print "Saving file <b>$output</b>, size=".strlen($rs->fields[0])."<p>";
$fd = fopen($output, "wb");
fwrite($fd, $rs->fields[0]);
fclose($fd);
print " <a href=file://$output>View Image</a>";
//$rs = $conn->Execute('SELECT id,SUBSTRING(b1, 1, 10) FROM blobtest');
//rs2html($rs);
?>

View file

@ -2,7 +2,7 @@
<body>
<?php
/*
V1.81 22 March 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
V2.12 12 June 2002 (c) 2000-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

@ -1,6 +1,6 @@
<?php
/*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
V2.12 12 June 2002 (c) 2000-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.
@ -11,44 +11,47 @@ V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reser
error_reporting(E_ALL);
$PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
include_once('../adodb-pear.inc.php');
include_once('../tohtml.inc.php');
session_register('curr_page');
include_once('../adodb.inc.php');
include_once('../adodb-pager.inc.php');
$db = NewADOConnection('mysql');
$db->debug = true;
//$db->Connect('localhost:4321','scott','tiger','natsoft.domain');
$db->Connect('localhost','root','','xphplens');
$driver = 'mysql';
$sql = 'select ID, firstname as "First Name", lastname as "Last Name", created as "Date Created" from adoxyz order by id';
$num_of_rows_per_page = 7;
$sql = "select * from adoxyz ";
if (isset($HTTP_GET_VARS['next_page']))
$curr_page = $HTTP_GET_VARS['next_page'];
if (empty($curr_page)) $curr_page = 1; ## at first page
$rs = $db->PageExecute($sql, $num_of_rows_per_page, $curr_page);
if (!$rs) die('Query Failed');
if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage())) {
if (!$rs->AtFirstPage()) {
?>
<a href="<?php echo $PHP_SELF;?>?next_page=1">First page</a> &nbsp;
<a href="<?php echo $PHP_SELF,'?next_page=',$rs->AbsolutePage() - 1 ?>">Previous page</a> &nbsp;
<?php
} else {
echo " First Page &nbsp; Previous Page &nbsp; ";
}
if (!$rs->AtLastPage()) {
?>
<a href="<?php echo $PHP_SELF,'?next_page=',$rs->AbsolutePage() + 1 ?>">Next Page</a>
<?php
} else
print "Next Page";
rs2html($rs);
if ($driver == 'access') {
$db = NewADOConnection('access');
$db->PConnect("nwind", "", "", "");
}
if ($driver == 'ibase') {
$db = NewADOConnection('ibase');
$db->PConnect("localhost:e:\\interbase\\examples\\database\\employee.gdb", "sysdba", "masterkey", "");
$sql = 'select ID, firstname , lastname , created from adoxyz order by id';
}
if ($driver == 'mssql') {
$db = NewADOConnection('mssql');
$db->Connect('(local)\NetSDK','','','northwind');
}
if ($driver == 'oci8') {
$db = NewADOConnection('oci8');
$db->Connect('','scott','tiger');
}
?>
if ($driver == 'access') {
$db = NewADOConnection('access');
$db->Connect('nwind');
}
if (empty($driver) or $driver == 'mysql') {
$db = NewADOConnection('mysql');
$db->Connect('localhost','root','','xphplens');
}
//$db->pageExecuteCountRows = false;
$db->debug = true;
$pager = new ADODB_Pager($db,$sql);
//$pager->cache = 60;
$pager->Render($rows=7);
?>

View file

@ -1,6 +1,6 @@
<?php
/*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
V2.12 12 June 2002 (c) 2000-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

@ -1,6 +1,6 @@
<?php
/*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
V2.12 12 June 2002 (c) 2000-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.
@ -11,14 +11,14 @@ V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reser
GLOBAL $HTTP_SESSION_VARS;
$ADODB_SESS_DEBUG = true;
include('adodb.inc.php');
include('adodb-session.php');
session_start();
session_register('AVAR');
$HTTP_SESSION_VARS['AVAR'] += 1;
$AVAR += 1;
error_reporting(E_ALL);
print "<p>\$HTTP_SESSION_VARS['AVAR']={$HTTP_SESSION_VARS['AVAR']}</p>";
$ADODB_SESS_DEBUG = true;
include('../adodb-session.php');
session_start();
if (!isset($HTTP_GET_VARS['nochange'])) $HTTP_SESSION_VARS['AVAR'] += 1;
print "<p><b>\$HTTP_SESSION_VARS['AVAR']={$HTTP_SESSION_VARS['AVAR']}</b></p>";
?>