--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\r
+\r
+<html>\r
+<head>\r
+ <title>ADODB Benchmarks</title>\r
+</head> \r
+\r
+<body>\r
+<?php \r
+/*\r
+V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ Released under both BSD license and Lesser GPL library license. \r
+ Whenever there is any discrepancy between the two licenses, \r
+ the BSD license will take precedence.\r
+ \r
+ Benchmark code to test the speed to the ADODB library with different databases.\r
+ This is a simplistic benchmark to be used as the basis for further testing.\r
+ It should not be used as proof of the superiority of one database over the other.\r
+*/ \r
+ \r
+//$testmssql = true;\r
+//$testvfp = true;\r
+$testoracle = true;\r
+//$testado = true; \r
+//$testibase = true;\r
+$testaccess = true;\r
+$testmysql = true;\r
+\r
+set_time_limit(240); // increase timeout\r
+\r
+include("../tohtml.inc.php");\r
+include("../adodb.inc.php");\r
+\r
+function testdb(&$db,$createtab="create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)")\r
+{\r
+GLOBAL $ADODB_version,$ADODB_FETCH_MODE;\r
+\r
+\r
+ $max = 100;\r
+ $sql = 'select * from ADOXYZ';\r
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;\r
+ \r
+ print "<h3>ADODB Version: $ADODB_version Host: <i>$db->host</i> Database: <i>$db->database</i></h3>";\r
+ \r
+ // perform query once to cache results so we are only testing throughput \r
+ $rs = $db->Execute($sql);\r
+ if (!$rs){\r
+ print "Error in recordset<p>";\r
+ return;\r
+ } \r
+ $arr = $rs->GetArray();\r
+ //$db->debug = true;\r
+\r
+ $start = microtime();\r
+ for ($i=0; $i < $max; $i++) {\r
+ $rs = $db->Execute($sql); \r
+ $arr = $rs->GetArray();\r
+ // print $arr[0][1];\r
+ }\r
+ $end = microtime();\r
+ $start = explode(' ',$start);\r
+ $end = explode(' ',$end);\r
+ \r
+ print_r($start);\r
+ print_r($end);\r
+ \r
+ // print_r($arr);\r
+ $total = $end[0]+trim($end[1]) - $start[0]-trim($start[1]);\r
+ printf ("<p>seconds = %8.2f for %d iterations each with %d records</p>",$total,$max, sizeof($arr));\r
+ flush();\r
+\r
+?>\r
+ </p>\r
+ <table width=100% ><tr><td bgcolor=beige> </td></tr></table>\r
+ </p>\r
+<?php\r
+ //$db->Close();\r
+}\r
+include("testdatabases.inc.php");\r
+\r
+?>\r
+\r
+\r
+</body>\r
+</html>\r
--- /dev/null
+<html>\r
+<body bgcolor=white>\r
+<?php\r
+/** \r
+ * (c)2001,2002 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ * Released under both BSD license and Lesser GPL library license. \r
+ Whenever there is any discrepancy between the two licenses, \r
+ the BSD license will take precedence. \r
+ * \r
+ * set tabs to 8\r
+ */\r
+ \r
+ // documentation on usage is at http://php.weblogs.com/adodb_csv\r
+ \r
+include('../adodb.inc.php');\r
+include('../tohtml.inc.php');\r
+\r
+ function &send2server($url,$sql)\r
+ {\r
+ $url .= '?sql='.urlencode($sql);\r
+ print "<p>$url</p>";\r
+ $rs = csv2rs($url,$err);\r
+ if ($err) print $err;\r
+ return $rs;\r
+ }\r
+ \r
+ function print_pre($s)\r
+ {\r
+ print "<pre>";print_r($s);print "</pre>";\r
+ }\r
+\r
+\r
+$serverURL = 'http://localhost/php/phplens/adodb/server.php';\r
+$testhttp = false;\r
+\r
+$sql1 = "insertz into products (productname) values ('testprod 1')";\r
+$sql2 = "insert into products (productname) values ('testprod 1')";\r
+$sql3 = "insert into products (productname) values ('testprod 2')";\r
+$sql4 = "delete from products where productid>80";\r
+$sql5 = 'select * from products';\r
+ \r
+if ($testhttp) {\r
+ print "<a href=#c>Client Driver Tests</a><p>";\r
+ print "<h3>Test Error</h3>";\r
+ $rs = send2server($serverURL,$sql1);\r
+ print_pre($rs);\r
+ print "<hr>";\r
+ \r
+ print "<h3>Test Insert</h3>";\r
+ \r
+ $rs = send2server($serverURL,$sql2);\r
+ print_pre($rs);\r
+ print "<hr>";\r
+ \r
+ print "<h3>Test Insert2</h3>";\r
+ \r
+ $rs = send2server($serverURL,$sql3);\r
+ print_pre($rs);\r
+ print "<hr>";\r
+ \r
+ print "<h3>Test Delete</h3>";\r
+ \r
+ $rs = send2server($serverURL,$sql4);\r
+ print_pre($rs);\r
+ print "<hr>";\r
+ \r
+ \r
+ print "<h3>Test Select</h3>";\r
+ $rs = send2server($serverURL,$sql5);\r
+ if ($rs) rs2html($rs);\r
+ \r
+ print "<hr>";\r
+}\r
+\r
+\r
+print "<a name=c><h1>CLIENT Driver Tests</h1>";\r
+$conn = ADONewConnection('csv');\r
+$conn->Connect($serverURL);\r
+$conn->debug = true;\r
+\r
+print "<h3>Bad SQL</h3>";\r
+\r
+$rs = $conn->Execute($sql1);\r
+\r
+print "<h3>Insert SQL 1</h3>";\r
+$rs = $conn->Execute($sql2);\r
+\r
+print "<h3>Insert SQL 2</h3>";\r
+$rs = $conn->Execute($sql3);\r
+\r
+print "<h3>Select SQL</h3>";\r
+$rs = $conn->Execute($sql5);\r
+if ($rs) rs2html($rs);\r
+\r
+print "<h3>Delete SQL</h3>";\r
+$rs = $conn->Execute($sql4);\r
+\r
+print "<h3>Select SQL</h3>";\r
+$rs = $conn->Execute($sql5);\r
+if ($rs) rs2html($rs);\r
+\r
+\r
+/* EXPECTED RESULTS FOR HTTP TEST:\r
+\r
+Test Insert\r
+http://localhost/php/adodb/server.php?sql=insert+into+products+%28productname%29+values+%28%27testprod%27%29\r
+\r
+adorecordset Object\r
+(\r
+ [dataProvider] => native\r
+ [fields] => \r
+ [blobSize] => 64\r
+ [canSeek] => \r
+ [EOF] => 1\r
+ [emptyTimeStamp] => \r
+ [emptyDate] => \r
+ [debug] => \r
+ [timeToLive] => 0\r
+ [bind] => \r
+ [_numOfRows] => -1\r
+ [_numOfFields] => 0\r
+ [_queryID] => 1\r
+ [_currentRow] => -1\r
+ [_closed] => \r
+ [_inited] => \r
+ [sql] => insert into products (productname) values ('testprod')\r
+ [affectedrows] => 1\r
+ [insertid] => 81\r
+)\r
+\r
+\r
+--------------------------------------------------------------------------------\r
+\r
+Test Insert2\r
+http://localhost/php/adodb/server.php?sql=insert+into+products+%28productname%29+values+%28%27testprod%27%29\r
+\r
+adorecordset Object\r
+(\r
+ [dataProvider] => native\r
+ [fields] => \r
+ [blobSize] => 64\r
+ [canSeek] => \r
+ [EOF] => 1\r
+ [emptyTimeStamp] => \r
+ [emptyDate] => \r
+ [debug] => \r
+ [timeToLive] => 0\r
+ [bind] => \r
+ [_numOfRows] => -1\r
+ [_numOfFields] => 0\r
+ [_queryID] => 1\r
+ [_currentRow] => -1\r
+ [_closed] => \r
+ [_inited] => \r
+ [sql] => insert into products (productname) values ('testprod')\r
+ [affectedrows] => 1\r
+ [insertid] => 82\r
+)\r
+\r
+\r
+--------------------------------------------------------------------------------\r
+\r
+Test Delete\r
+http://localhost/php/adodb/server.php?sql=delete+from+products+where+productid%3E80\r
+\r
+adorecordset Object\r
+(\r
+ [dataProvider] => native\r
+ [fields] => \r
+ [blobSize] => 64\r
+ [canSeek] => \r
+ [EOF] => 1\r
+ [emptyTimeStamp] => \r
+ [emptyDate] => \r
+ [debug] => \r
+ [timeToLive] => 0\r
+ [bind] => \r
+ [_numOfRows] => -1\r
+ [_numOfFields] => 0\r
+ [_queryID] => 1\r
+ [_currentRow] => -1\r
+ [_closed] => \r
+ [_inited] => \r
+ [sql] => delete from products where productid>80\r
+ [affectedrows] => 2\r
+ [insertid] => 0\r
+)\r
+\r
+[more stuff deleted]\r
+ .\r
+ . \r
+ .\r
+*/\r
+?>\r
--- /dev/null
+<?php\r
+\r
+/* \r
+V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ Released under both BSD license and Lesser GPL library license. \r
+ Whenever there is any discrepancy between the two licenses, \r
+ the BSD license will take precedence. \r
+ Set tabs to 4 for best viewing.\r
+ \r
+ Latest version is available at http://php.weblogs.com/\r
+*/\r
+\r
+\r
+foreach($HTTP_GET_VARS as $k=>$v) {\r
+ global $$k;\r
+ \r
+ $$k = $v;\r
+} \r
+\r
+if (sizeof($HTTP_GET_VARS) == 0) $testmysql = true;\r
+?>\r
+<html>\r
+<title>ADODB Testing</title>\r
+<body bgcolor=white>\r
+<H1>ADODB Test</H1>\r
+\r
+This script tests the following databases: Interbase, Oracle, Visual FoxPro, Microsoft Access (ODBC and ADO), MySQL, MSSQL (ODBC, native, ADO). \r
+There is also support for Sybase, PostgreSQL.</p>\r
+For the latest version of ADODB, visit <a href=http://php.weblogs.com/ADODB>php.weblogs.com</a>.</p>\r
+\r
+<form method=get>\r
+<input type=checkbox name=testaccess value=1 <?php echo !empty($testaccess) ? 'checked' : '' ?>> Access<br>\r
+<input type=checkbox name=testibase value=1 <?php echo !empty($testibase) ? 'checked' : '' ?>> Interbase<br>\r
+<input type=checkbox name=testmssql value=1 <?php echo !empty($testmssql) ? 'checked' : '' ?>> MSSQL<br>\r
+ <input type=checkbox name=testmysql value=1 <?php echo !empty($testmysql) ? 'checked' : '' ?>> <b>MySQL</b><br>\r
+<input type=checkbox name=testoracle value=1 <?php echo !empty($testoracle) ? 'checked' : '' ?>> <b>Oracle (oci8)</b> <br>\r
+<input type=checkbox name=testpostgres value=1 <?php echo !empty($testpostgres) ? 'checked' : '' ?>> <b>PostgreSQL</b><br>\r
+<input type=checkbox name=testvfp value=1 <?php echo !empty($testvfp) ? 'checked' : '' ?>> VFP<br>\r
+<input type=checkbox name=testado value=1 <?php echo !empty($testado) ? 'checked' : '' ?>> ADO (for mssql and access)<br>\r
+<input type=submit>\r
+</form>\r
+\r
+Test <a href=test4.php>GetInsertSQL/GetUpdateSQL</a> \r
+ <a href=testsessions.php>Sessions</a> \r
+ <a href=testpaging.php>Paging</a> \r
+<?php\r
+\r
+\r
+// Set the following control flags to true/false to enable testing for a particular database.\r
+/*\r
+$testoracle = true;\r
+$testibase = true;\r
+$testaccess = true;\r
+//testpostgres = true;\r
+$testmysql = true;\r
+//$testmssql = true;\r
+//$testvfp = true;\r
+//$testado = true;\r
+*/\r
+\r
+error_reporting(E_ALL);\r
+\r
+set_time_limit(240); // increase timeout\r
+\r
+include("../tohtml.inc.php");\r
+include("../adodb.inc.php");\r
+\r
+if ($ADODB_FETCH_MODE != ADODB_FETCH_DEFAULT) print "<h3>FETCH MODE IS NOT ADODB_FETCH_DEFAULT</h3>";\r
+\r
+// the table creation code is specific to the database, so we allow the user \r
+// to define their own table creation stuff\r
+function testdb(&$db,$createtab="create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)")\r
+{\r
+GLOBAL $ADODB_vers,$ADODB_CACHE_DIR,$ADODB_FETCH_MODE, $HTTP_GET_VARS,$ADODB_COUNTRECS;\r
+?> <form>\r
+ </p>\r
+ <table width=100% ><tr><td bgcolor=beige> </td></tr></table>\r
+ </p>\r
+<?php \r
+ $create =false;\r
+ $ADODB_CACHE_DIR = dirname(TempNam('/tmp','testadodb'));\r
+ \r
+ $db->debug = false;\r
+ \r
+ $phpv = phpversion();\r
+ print "<h3>ADODB Version: $ADODB_vers Host: <i>$db->host</i> Database: <i>$db->database</i> PHP: $phpv</h3>";\r
+ $e = error_reporting(E_ALL-E_WARNING);\r
+ \r
+ \r
+ print "<i>date1</i> (1999-02-20) = ".$db->DBDate('1999-2-20');\r
+ print "<br><i>date2</i> (1970-1-2) = ".$db->DBDate(24*3600)."<p>";\r
+ print "<i>ts1</i> (1999-02-20 3:40:50) = ".$db->DBTimeStamp('1999-2-20 3:40:50');\r
+ print "<br><i>ts2</i> (1999-02-20) = ".$db->DBTimeStamp('1999-2-20');\r
+ print "<br><i>ts3</i> (1970-1-2 +/- timezone) = ".$db->DBTimeStamp(24*3600);\r
+ $dd = $db->UnixDate('1999-02-20');\r
+ print "<br>unixdate</i> 1999-02-20 = ".date('Y-m-d',$dd)."<p>";\r
+ // mssql too slow in failing bad connection\r
+ if ($db->databaseType != 'mssql') {\r
+ print "<p>Testing bad connection. Ignore following error msgs:<br>";\r
+ $db2 = ADONewConnection();\r
+ $rez = $db2->Connect("bad connection");\r
+ $err = $db2->ErrorMsg();\r
+ print "<i>Error='$err'</i></p>";\r
+ if ($rez) print "<b>Cannot check if connection failed.</b> The Connect() function returned true.</p>";\r
+ }\r
+ error_reporting($e);\r
+ \r
+ //$ADODB_COUNTRECS=false;\r
+ $rs=$db->Execute('select * from adoxyz order by id');\r
+ //print_r($rs);\r
+ //OCIFetchStatement($rs->_queryID,$rez,0,-1);//,OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW);\r
+ //print_r($rez);\r
+ //die();\r
+ if($rs === false) $create = true;\r
+ else $rs->Close();\r
+ \r
+ //if ($db->databaseType !='vfp') $db->Execute("drop table ADOXYZ");\r
+ \r
+ if ($create) {\r
+ if ($db->databaseType == 'ibase') {\r
+ print "<b>Please create the following table for testing:</b></p>$createtab</p>";\r
+ return;\r
+ } else {\r
+ $db->debug = 1;\r
+ $e = error_reporting(E_ALL-E_WARNING);\r
+ $db->Execute($createtab);\r
+ error_reporting($e);\r
+ }\r
+ }\r
+ \r
+ $rs = &$db->Execute("delete from ADOXYZ"); // some ODBC drivers will fail the drop so we delete\r
+ if ($rs) {\r
+ if(! $rs->EOF)print "<b>Error: </b>RecordSet returned by Execute('delete...') should show EOF</p>";\r
+ $rs->Close();\r
+ } else print "err=".$db->ErrorMsg();\r
+ \r
+ print "<p>Test select on empty table</p>";\r
+ $rs = &$db->Execute("select * from ADOXYZ where id=9999");\r
+ if ($rs && !$rs->EOF) print "<b>Error: </b>RecordSet returned by Execute(select...') on empty table should show EOF</p>";\r
+ if ($rs) $rs->Close();\r
+ \r
+ \r
+ $db->debug=false; \r
+ print "<p>Testing Commit: ";\r
+ $time = $db->DBDate(time());\r
+ if (!$db->BeginTrans()) print '<b>Transactions not supported</b></p>';\r
+ else { /* COMMIT */\r
+ $rs = $db->Execute("insert into ADOXYZ values (99,'Should Not','Exist (Commit)',$time)");\r
+ if ($rs && $db->CommitTrans()) {\r
+ $rs->Close();\r
+ $rs = &$db->Execute("select * from ADOXYZ where id=99");\r
+ if ($rs === false || $rs->EOF) {\r
+ print '<b>Data not saved</b></p>';\r
+ $rs = &$db->Execute("select * from ADOXYZ where id=99");\r
+ print_r($rs);\r
+ die();\r
+ } else print 'OK</p>';\r
+ if ($rs) $rs->Close();\r
+ } else\r
+ print "<b>Commit failed</b></p>";\r
+ \r
+ /* ROLLBACK */ \r
+ if (!$db->BeginTrans()) print "<p><b>Error in BeginTrans</b>()</p>";\r
+ print "<p>Testing Rollback: ";\r
+ $db->Execute("insert into ADOXYZ values (100,'Should Not','Exist (Rollback)',$time)");\r
+ if ($db->RollbackTrans()) {\r
+ $rs = $db->Execute("select * from ADOXYZ where id=100");\r
+ if ($rs && !$rs->EOF) print '<b>Fail: Data should rollback</b></p>';\r
+ else print 'OK</p>';\r
+ if ($rs) $rs->Close();\r
+ } else\r
+ print "<b>Commit failed</b></p>";\r
+ \r
+ $rs = &$db->Execute('delete from ADOXYZ where id>50');\r
+ if ($rs) $rs->Close();\r
+ }\r
+ \r
+ if (1) {\r
+ print "<p>Testing MetaDatabases()</p>";\r
+ print_r( $db->MetaDatabases());\r
+ \r
+ print "<p>Testing MetaTables() and MetaColumns()</p>";\r
+ $a = $db->MetaTables();\r
+ if ($a===false) print "<b>MetaTables not supported</b></p>";\r
+ else {\r
+ print "Array of tables: "; \r
+ foreach($a as $v) print " ($v) ";\r
+ print '</p>';\r
+ }\r
+ $a = $db->MetaColumns('ADOXYZ');\r
+ if ($a===false) print "<b>MetaColumns not supported</b></p>";\r
+ else {\r
+ print "<p>Columns of ADOXYZ: ";\r
+ foreach($a as $v) print " ($v->name $v->type $v->max_length) ";\r
+ }\r
+ }\r
+ $rs = &$db->Execute('delete from ADOXYZ');\r
+ if ($rs) $rs->Close();\r
+ \r
+ $db->debug = false;\r
+ \r
+ if ($db->databaseType == 'mssql') {\r
+/*\r
+ASSUME Northwind available...\r
+\r
+CREATE PROCEDURE SalesByCategory\r
+ @CategoryName nvarchar(15), @OrdYear nvarchar(4) = '1998'\r
+AS\r
+IF @OrdYear != '1996' AND @OrdYear != '1997' AND @OrdYear != '1998' \r
+BEGIN\r
+ SELECT @OrdYear = '1998'\r
+END\r
+\r
+SELECT ProductName,\r
+ TotalPurchase=ROUND(SUM(CONVERT(decimal(14,2), OD.Quantity * (1-OD.Discount) * OD.UnitPrice)), 0)\r
+FROM [Order Details] OD, Orders O, Products P, Categories C\r
+WHERE OD.OrderID = O.OrderID \r
+ AND OD.ProductID = P.ProductID \r
+ AND P.CategoryID = C.CategoryID\r
+ AND C.CategoryName = @CategoryName\r
+ AND SUBSTRING(CONVERT(nvarchar(22), O.OrderDate, 111), 1, 4) = @OrdYear\r
+GROUP BY ProductName\r
+ORDER BY ProductName\r
+GO\r
+*/\r
+ print "<h4>Testing Stored Procedures for mssql</h4>";\r
+ $saved = $db->debug;\r
+ $db->debug=true;\r
+ \r
+ $cat = 'Dairy Products';\r
+ $yr = '1998';\r
+ \r
+ $stmt = $db->PrepareSP('SalesByCategory');\r
+ $db->Parameter($stmt,$cat,'CategoryName');\r
+ $db->Parameter($stmt,$yr,'OrdYear');\r
+ $rs = $db->Execute($stmt);\r
+ rs2html($rs);\r
+ \r
+ $cat = 'Grains/Cereals';\r
+ $yr = 1998;\r
+ \r
+ $stmt = $db->PrepareSP('SalesByCategory');\r
+ $db->Parameter($stmt,$cat,'CategoryName');\r
+ $db->Parameter($stmt,$yr,'OrdYear');\r
+ $rs = $db->Execute($stmt);\r
+ rs2html($rs);\r
+ \r
+ $db->debug = $saved;\r
+ } else if (substr($db->databaseType,0,4) == 'oci8') {\r
+ print "<h4>Testing Stored Procedures for oci8</h4>";\r
+ $saved = $db->debug;\r
+ $db->debug=true;\r
+ \r
+ $tname = 'A%';\r
+ \r
+ $stmt = $db->PrepareSP('select * from tab where tname like :tablename');\r
+ $db->Parameter($stmt,$tname,'tablename');\r
+ $rs = $db->Execute($stmt);\r
+ rs2html($rs);\r
+ \r
+ $db->debug = $saved;\r
+ }\r
+ print "<p>Inserting 50 rows</p>";\r
+\r
+ for ($i = 0; $i < 5; $i++) { \r
+ \r
+ $time = $db->DBDate(time());\r
+ if (empty($HTTP_GET_VARS['hide'])) $db->debug = true;\r
+ switch($db->databaseType){\r
+ default:\r
+ $arr = array(0=>'Caroline',1=>'Miranda');\r
+ $sql = "insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+0,?,?,$time)";\r
+ break;\r
+ case 'oci8':\r
+ case 'oci805':\r
+ $arr = array('first'=>'Caroline','last'=>'Miranda');\r
+ $sql = "insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+0,:first,:last,$time)"; \r
+ break;\r
+ }\r
+ if ($i & 1) {\r
+ $sql = $db->Prepare($sql);\r
+ }\r
+ $rs = $db->Execute($sql,$arr);\r
+ \r
+ if ($rs === false) print '<b>Error inserting with parameters</b><br>';\r
+ else $rs->Close();\r
+ \r
+ $db->debug = false;\r
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+1,'John','Lim',$time)");\r
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+2,'Mary','Lamb',$time )");\r
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+3,'George','Washington',$time )");\r
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+4,'Mr. Alan','Tam',$time )");\r
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+5,'Alan','Turing',$time )");\r
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created)values ($i*10+6,'Serena','Williams',$time )");\r
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+7,'Yat Sun','Sun',$time )");\r
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+8,'Wai Hun','See',$time )");\r
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+9,'Steven','Oey',$time )");\r
+ }\r
+ \r
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;\r
+ \r
+ $db->Execute('update ADOXYZ set id=id+1');\r
+ $nrows = $db->Affected_Rows();\r
+ if ($nrows === false) print "<p><b>Affected_Rows() not supported</b></p>";\r
+ else if ($nrows != 50) print "<p><b>Affected_Rows() Error: $nrows returned (should be 50) </b></p>";\r
+ else print "<p>Affected_Rows() passed</p>";\r
+ $db->debug = false;\r
+\r
+ $ADODB_FETCH_MODE = ADODB_FETCH_BOTH;\r
+ ///////////////////////////////\r
+ \r
+ $rs = &$db->Execute("select * from ADOXYZ order by id");\r
+ if ($rs) {\r
+ // print_r($rs);\r
+ if ($rs->RecordCount() != 50) {\r
+ print "<p><b>RecordCount returns -1</b></p>";\r
+ if ($rs->PO_RecordCount('ADOXYZ') == 50) print "<p> PO_RecordCount passed</p>";\r
+ else print "<p><b>PO_RecordCount returns wrong value</b></p>";\r
+ } else print "<p>RecordCount() passed</p>";\r
+ if (isset($rs->fields['firstname'])) print '<p>The fields columns can be indexed by column name.</p>';\r
+ else print '<p>The fields columns <i>cannot</i> be indexed by column name.</p>';\r
+ if (empty($HTTP_GET_VARS['hide'])) rs2html($rs);\r
+ }\r
+ else print "<b>Error in Execute of SELECT</b></p>";\r
+ \r
+ $val = $db->GetOne("select count(*) from ADOXYZ");\r
+ if ($val == 50) print "<p>GetOne returns ok</p>";\r
+ else print "<p><b>Fail: GetOne returns $val</b></p>";\r
+\r
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;\r
+ $val = $db->GetRow("select count(*) from ADOXYZ");\r
+ if ($val[0] == 50 and sizeof($val) == 1) print "<p>GetRow returns ok</p>";\r
+ else {\r
+ print_r($val);\r
+ print "<p><b>Fail: GetRow returns {$val[0]}</b></p>";\r
+ }\r
+\r
+ print "<p>FetchObject/FetchNextObject Test</p>";\r
+ $rs = &$db->Execute('select * from ADOXYZ');\r
+ if (empty($rs->connection)) print "<b>Connection object missing from recordset</b></br>";\r
+ \r
+ while ($o = $rs->FetchNextObject()) { // calls FetchObject internally\r
+ if (!is_string($o->FIRSTNAME) || !is_string($o->LASTNAME)) {\r
+ print_r($o);\r
+ print "<p><b>Firstname is not string</b></p>";\r
+ break;\r
+ }\r
+ }\r
+ \r
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;\r
+ print "<p>FetchObject/FetchNextObject Test 2</p>";\r
+ $rs = &$db->Execute('select * from ADOXYZ');\r
+ if (empty($rs->connection)) print "<b>Connection object missing from recordset</b></br>";\r
+ \r
+ while ($o = $rs->FetchNextObject()) { // calls FetchObject internally\r
+ if (!is_string($o->FIRSTNAME) || !is_string($o->LASTNAME)) {\r
+ print_r($o);\r
+ print "<p><b>Firstname is not string</b></p>";\r
+ break;\r
+ }\r
+ }\r
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;\r
+ \r
+ $savefetch = $ADODB_FETCH_MODE;\r
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;\r
+ \r
+ print "<p>CacheSelectLimit Test</p>";\r
+ $rs = $db->CacheSelectLimit('select id, firstname from ADOXYZ order by id',2);\r
+ if ($rs && !$rs->EOF) {\r
+ if ($rs->fields['id'] != 1) {print "<b>Error 1</b><br>"; print_r($rs->fields);};\r
+ if (trim($rs->fields['firstname']) != 'Caroline') {print "<b>Error 2</b><br>"; print_r($rs->fields);};\r
+ $rs->MoveNext();\r
+ if ($rs->fields['id'] != 2) {print "<b>Error 3</b><br>"; print_r($rs->fields);};\r
+ $rs->MoveNext();\r
+ if (!$rs->EOF) print "<b>EOF Error</b><br>";\r
+ }\r
+ \r
+ print "<p>FETCH_MODE = ASSOC: Should get 1, Caroline</p>";\r
+ $rs = &$db->SelectLimit('select id,firstname from ADOXYZ order by id',2);\r
+ if ($rs && !$rs->EOF) {\r
+ if ($rs->fields['id'] != 1) {print "<b>Error 1</b><br>"; print_r($rs->fields);};\r
+ if (trim($rs->fields['firstname']) != 'Caroline') {print "<b>Error 2</b><br>"; print_r($rs->fields);};\r
+ $rs->MoveNext();\r
+ if ($rs->fields['id'] != 2) {print "<b>Error 3</b><br>"; print_r($rs->fields);};\r
+ $rs->MoveNext();\r
+ if (!$rs->EOF) print "<b>EOF Error</b><br>";\r
+ }\r
+ \r
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;\r
+ print "<p>FETCH_MODE = NUM: Should get 1, Caroline</p>";\r
+ $rs = &$db->SelectLimit('select id,firstname from ADOXYZ order by id',1);\r
+ if ($rs && !$rs->EOF) {\r
+ if ($rs->fields[0] != 1) {print "<b>Error 1</b><br>"; print_r($rs->fields);};\r
+ if (trim($rs->fields[1]) != 'Caroline') {print "<b>Error 2</b><br>"; print_r($rs->fields);};\r
+ $rs->MoveNext();\r
+ if (!$rs->EOF) print "<b>EOF Error</b><br>";\r
+\r
+ }\r
+ $ADODB_FETCH_MODE = $savefetch;\r
+ \r
+ $db->debug = false;\r
+ print "<p>GetRowAssoc Upper: Should get 1, Caroline</p>";\r
+ $rs = &$db->SelectLimit('select id,firstname from ADOXYZ order by id',1);\r
+ if ($rs && !$rs->EOF) {\r
+ $arr = &$rs->GetRowAssoc();\r
+ if ($arr['ID'] != 1) {print "<b>Error 1</b><br>"; print_r($arr);};\r
+ if (trim($arr['FIRSTNAME']) != 'Caroline') {print "<b>Error 2</b><br>"; print_r($arr);};\r
+ $rs->MoveNext();\r
+ if (!$rs->EOF) print "<b>EOF Error</b><br>";\r
+\r
+ }\r
+ print "<p>GetRowAssoc Lower: Should get 1, Caroline</p>";\r
+ $rs = &$db->SelectLimit('select id,firstname from ADOXYZ order by id',1);\r
+ if ($rs && !$rs->EOF) {\r
+ $arr = &$rs->GetRowAssoc(false);\r
+ if ($arr['id'] != 1) {print "<b>Error 1</b><br>"; print_r($arr);};\r
+ if (trim($arr['firstname']) != 'Caroline') {print "<b>Error 2</b><br>"; print_r($arr);};\r
+\r
+ }\r
+ //$db->debug = true;\r
+ print "<p>SelectLimit Test 1: Should see Caroline, John and Mary</p>";\r
+ $rs = &$db->SelectLimit('select distinct * from ADOXYZ order by id',3);\r
+ if ($rs && !$rs->EOF) {\r
+ if (trim($rs->fields[1]) != 'Caroline') print "<b>Error 1</b><br>";\r
+ $rs->MoveNext();\r
+ if (trim($rs->fields[1]) != 'John') print "<b>Error 2</b><br>";\r
+ $rs->MoveNext();\r
+ if (trim($rs->fields[1]) != 'Mary') print "<b>Error 3</b><br>";\r
+ $rs->MoveNext();\r
+ if (! $rs->EOF) print "<b>Not EOF</b><br>";\r
+ //rs2html($rs);\r
+ }\r
+ else "<p><b>Failed SelectLimit Test 1</b></p>";\r
+ print "<p>SelectLimit Test 2: Should see Mary, George and Mr. Alan</p>";\r
+ $rs = &$db->SelectLimit('select * from ADOXYZ order by id',3,2);\r
+ if ($rs && !$rs->EOF) {\r
+ if (trim($rs->fields[1]) != 'Mary') print "<b>Error 1</b><br>";\r
+ $rs->MoveNext();\r
+ if (trim($rs->fields[1]) != 'George') print "<b>Error 2</b><br>";\r
+ $rs->MoveNext();\r
+ if (trim($rs->fields[1]) != 'Mr. Alan') print "<b>Error 3</b><br>";\r
+ $rs->MoveNext();\r
+ if (! $rs->EOF) print "<b>Not EOF</b><br>";\r
+ // rs2html($rs);\r
+ }\r
+ else "<p><b>Failed SelectLimit Test 2</b></p>";\r
+ \r
+ print "<p>SelectLimit Test 3: Should see Wai Hun and Steven</p>";\r
+ $rs = &$db->SelectLimit('select * from ADOXYZ order by id',-1,48);\r
+ if ($rs && !$rs->EOF) {\r
+ if (empty($rs->connection)) print "<b>Connection object missing from recordset</b></br>";\r
+ if (trim($rs->fields[1]) != 'Wai Hun') print "<b>Error 1</b><br>";\r
+ $rs->MoveNext();\r
+ if (trim($rs->fields[1]) != 'Steven') print "<b>Error 2</b><br>";\r
+ $rs->MoveNext();\r
+ if (! $rs->EOF) print "<b>Not EOF</b><br>";\r
+ //rs2html($rs);\r
+ }\r
+ else "<p><b>Failed SelectLimit Test 3</b></p>";\r
+ $db->debug = false;\r
+ \r
+ $rs = &$db->Execute("select * from ADOXYZ order by id");\r
+ print "<p>Testing Move()</p>"; \r
+ if (!$rs)print "<b>Failed Move SELECT</b></p>";\r
+ else {\r
+ if (!$rs->Move(2)) {\r
+ if (!$rs->canSeek) print "<p>$db->databaseType: <b>Move(), MoveFirst() nor MoveLast() not supported.</b></p>";\r
+ else print '<p><b>RecordSet->canSeek property should be set to false</b></p>';\r
+ } else {\r
+ $rs->MoveFirst();\r
+ if (trim($rs->Fields("firstname")) != 'Caroline') {\r
+ print "<p><b>$db->databaseType: MoveFirst failed -- probably cannot scroll backwards</b></p>";\r
+ }\r
+ else print "MoveFirst() OK<BR>";\r
+ \r
+ // Move(3) tests error handling -- MoveFirst should not move cursor\r
+ $rs->Move(3);\r
+ if (trim($rs->Fields("firstname")) != 'George') {\r
+ print '<p>'.$rs->Fields("id")."<b>$db->databaseType: Move(3) failed</b></p>";\r
+ print_r($rs);\r
+ } else print "Move(3) OK<BR>";\r
+ \r
+ $rs->Move(7);\r
+ if (trim($rs->Fields("firstname")) != 'Yat Sun') {\r
+ print '<p>'.$rs->Fields("id")."<b>$db->databaseType: Move(7) failed</b></p>";\r
+ print_r($rs);\r
+ } else print "Move(7) OK<BR>";\r
+\r
+ $rs->MoveLast();\r
+ if (trim($rs->Fields("firstname")) != 'Steven'){\r
+ print '<p>'.$rs->Fields("id")."<b>$db->databaseType: MoveLast() failed</b></p>";\r
+ print_r($rs);\r
+ }else print "MoveLast() OK<BR>";\r
+ }\r
+ }\r
+ \r
+ // $db->debug=true;\r
+ print "<p>Testing ADODB_FETCH_ASSOC and concat: concat firstname and lastname</p>";\r
+ \r
+ $save = $ADODB_FETCH_MODE;\r
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;\r
+ if ($db->dataProvider == 'postgres')\r
+ $rs = &$db->Execute("select distinct ".$db->Concat('(firstname',$db->qstr(' ').')','lastname').",id from ADOXYZ");\r
+ else\r
+ $rs = &$db->Execute("select distinct ".$db->Concat('firstname',$db->qstr(' '),'lastname').",id from ADOXYZ");\r
+ if ($rs) {\r
+ if (empty($HTTP_GET_VARS['hide'])) rs2html($rs);\r
+ } else print "<b>Failed Concat</b></p>";\r
+ \r
+ $ADODB_FETCH_MODE = $save;\r
+ print "<hr>Testing GetArray() ";\r
+ $rs = &$db->Execute("select * from ADOXYZ order by id");\r
+ if ($rs) {\r
+ $arr = &$rs->GetArray(10);\r
+ if (sizeof($arr) != 10 || trim($arr[1][1]) != 'John' || trim($arr[1][2]) != 'Lim') print $arr[1][1].' '.$arr[1][2]."<b> ERROR</b><br>";\r
+ else print " OK<BR>";\r
+ }\r
+ \r
+ print "Testing FetchNextObject for 1 object ";\r
+ $rs = &$db->Execute("select distinct lastname,firstname from ADOXYZ where firstname='Caroline'");\r
+ $fcnt = 0;\r
+ if ($rs)\r
+ while ($o = $rs->FetchNextObject()) {\r
+ $fcnt += 1; \r
+ }\r
+ if ($fcnt == 1) print " OK<BR>";\r
+ else print "<b>FAILED</b><BR>";\r
+ \r
+ print "Testing GetAssoc() ";\r
+ $rs = &$db->Execute("select distinct lastname,firstname from ADOXYZ");\r
+ if ($rs) {\r
+ $arr = $rs->GetAssoc();\r
+ if (trim($arr['See']) != 'Wai Hun') print $arr['See']." <b>ERROR</b><br>";\r
+ else print " OK<BR>";\r
+ }\r
+ \r
+ for ($loop=0; $loop < 1; $loop++) {\r
+ print "Testing GetMenu() and CacheExecute<BR>";\r
+ $db->debug = true;\r
+ $rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ");\r
+ if ($rs) print 'With blanks, Steven selected:'. $rs->GetMenu('menu','Steven').'<BR>'; \r
+ else print " Fail<BR>";\r
+ $rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ");\r
+ if ($rs) print ' No blanks, Steven selected: '. $rs->GetMenu('menu','Steven',false).'<BR>';\r
+ else print " Fail<BR>";\r
+ \r
+ $rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ");\r
+ if ($rs) print ' Multiple, Alan selected: '. $rs->GetMenu('menu','Alan',false,true).'<BR>';\r
+ else print " Fail<BR>";\r
+ print '</p><hr>';\r
+ \r
+ $rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ");\r
+ if ($rs) {\r
+ print ' Multiple, Alan and George selected: '. $rs->GetMenu('menu',array('Alan','George'),false,true);\r
+ if (empty($rs->connection)) print "<b>Connection object missing from recordset</b></br>";\r
+ } else print " Fail<BR>";\r
+ print '</p><hr>';\r
+ \r
+ print "Testing GetMenu2() <BR>";\r
+ $rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ");\r
+ if ($rs) print 'With blanks, Steven selected:'. $rs->GetMenu2('menu',('Oey')).'<BR>'; \r
+ else print " Fail<BR>";\r
+ $rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ");\r
+ if ($rs) print ' No blanks, Steven selected: '. $rs->GetMenu2('menu',('Oey'),false).'<BR>';\r
+ else print " Fail<BR>";\r
+ }\r
+ \r
+ $db->debug = false;\r
+ $rs1 = &$db->Execute("select id from ADOXYZ where id = 2 or id = 1 order by 1");\r
+ $rs2 = &$db->Execute("select id from ADOXYZ where id = 3 or id = 4 order by 1");\r
+ \r
+ if ($rs1) $rs1->MoveLast();\r
+ if ($rs2) $rs2->MoveLast();\r
+ \r
+ if (empty($rs1) || empty($rs2) || $rs1->fields[0] != 2 || $rs2->fields[0] != 4) {\r
+ $a = $rs1->fields[0];\r
+ $b = $rs2->fields[0];\r
+ print "<p><b>Error in multiple recordset test rs1=$a rs2=%b (should be rs1=2 rs2=4)</b></p>";\r
+ } else\r
+ print "<p>Testing multiple recordsets OK</p>";\r
+ \r
+ \r
+ echo "<p> GenID test: ";\r
+ for ($i=1; $i <= 10; $i++) \r
+ echo "($i: ",$val = $db->GenID('abcseq5' ,5), ") ";\r
+ if ($val == 0) echo " <p><b>GenID not supported</b>";\r
+ echo "<p>";\r
+ \r
+ if (substr($db->dataProvider,0,3) != 'ado') { // crashes ado\r
+ $sql = "select firstnames from adoxyz";\r
+ print "<p>Testing execution of illegal statement: <i>$sql</i></p>";\r
+ if ($db->Execute($sql) === false) {\r
+ print "<p>This returns the following ErrorMsg(): <i>".$db->ErrorMsg()."</i> and ErrorNo(): ".$db->ErrorNo().'</p>';\r
+ } else \r
+ print "<p><b>Error in error handling -- Execute() should return false</b></p>";\r
+ } else \r
+ print "<p><b>ADO skipped error handling of bad select statement</b></p>";\r
+ \r
+ print "<p>ASSOC TEST 2<br>";\r
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;\r
+ $rs = $db->query('select * from adoxyz order by id');\r
+ for($i=0;$i<$rs->FieldCount();$i++) \r
+ { \r
+ $fld=$rs->FetchField($i); \r
+ print "<br> Field name is ".$fld->name; \r
+ print " ".$rs->Fields($fld->name); \r
+ } \r
+\r
+ \r
+ print "<p>BOTH TEST 2<br>";\r
+ if ($db->dataProvider == 'ado') {\r
+ print "<b>ADODB_FETCH_BOTH not supported</b> for dataProvider=".$db->dataProvider."<br>";\r
+ } else {\r
+ $ADODB_FETCH_MODE = ADODB_FETCH_BOTH;\r
+ $rs = $db->query('select * from adoxyz order by id');\r
+ for($i=0;$i<$rs->FieldCount();$i++) \r
+ { \r
+ $fld=$rs->FetchField($i); \r
+ print "<br> Field name is ".$fld->name; \r
+ print " ".$rs->Fields($fld->name); \r
+ } \r
+ }\r
+ \r
+ print "<p>NUM TEST 2<br>";\r
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;\r
+ $rs = $db->query('select * from adoxyz order by id');\r
+ for($i=0;$i<$rs->FieldCount();$i++) \r
+ { \r
+ $fld=$rs->FetchField($i); \r
+ print "<br> Field name is ".$fld->name; \r
+ print " ".$rs->Fields($fld->name); \r
+ } \r
+ \r
+ print "<p>ASSOC Test of SelectLimit<br>";\r
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;\r
+ $rs = $db->selectlimit('select * from adoxyz order by id',3,4);\r
+ $cnt = 0;\r
+ while ($rs && !$rs->EOF) {\r
+ $cnt += 1;\r
+ if (!isset($rs->fields['firstname'])) {\r
+ print "<br><b>ASSOC returned numeric field</b></p>";\r
+ break;\r
+ }\r
+ $rs->MoveNext();\r
+ }\r
+ if ($cnt != 3) print "<br><b>Count should be 3, instead it was $cnt</b></p>";\r
+ \r
+ \r
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;\r
+ if ($db->sysDate) {\r
+ $saved = $db->debug;\r
+ $db->debug = 1;\r
+ $rs = $db->Execute("select {$db->sysDate} from adoxyz where id=1");\r
+ if (ADORecordSet::UnixDate(date('Y-m-d')) != $rs->UnixDate($rs->fields[0])) {\r
+ print "<p><b>Invalid date {$rs->fields[0]}</b></p>";\r
+ } else\r
+ print "<p>Passed \$sysDate test ({$rs->fields[0]})</p>";\r
+ \r
+ $db->debug=$saved;\r
+ } else {\r
+ print "<p><b>\$db->sysDate not defined</b></p>";\r
+ }\r
+ // PEAR TESTS BELOW\r
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;\r
+ $pear = true;\r
+ $rs = $db->query('select * from adoxyz order by id');\r
+ \r
+ $i = 0;\r
+ if ($rs && !$rs->EOF) {\r
+ while ($arr = $rs->fetchRow()) {\r
+ $i++;\r
+ //print "$i ";\r
+ if ($arr[0] != $i) {\r
+ print "<p><b>PEAR DB emulation error 1.</b></p>";\r
+ $pear = false;\r
+ break;\r
+ }\r
+ }\r
+ $rs->Close();\r
+ }\r
+\r
+ \r
+ include_once "PEAR.php";\r
+ $db->debug =true;\r
+ if ($i != 50) {\r
+ print "<p><b>PEAR DB emulation error 1.1 EOF ($i)</b></p>";\r
+ $pear = false;\r
+ }\r
+ \r
+ $rs = $db->limitQuery('select * from adoxyz order by id',$i=3,$top=3);\r
+ $i2 = $i;\r
+ if ($rs && !$rs->EOF) {\r
+\r
+ while (!is_object($rs->fetchInto($arr))) {\r
+ $i2++;\r
+ \r
+ // print_r($arr);\r
+ // print "$i ";print_r($arr);\r
+ if ($arr[0] != $i2) {\r
+ print "<p><b>PEAR DB emulation error 2.</b></p>";\r
+ $pear = false;\r
+ break;\r
+ }\r
+ }\r
+ $rs->Close();\r
+ }\r
+ if ($i2 != $i+$top) {\r
+ print "<p><b>PEAR DB emulation error 2.1 EOF (correct=$i+$top, actual=$i2)</b></p>";\r
+ $pear = false;\r
+ }\r
+ \r
+ if ($pear) print "<p>PEAR DB emulation passed.</p>";\r
+ \r
+\r
+ global $TESTERRS;\r
+ $db->debug = false;\r
+ $TESTERRS = 0;\r
+ $db->raiseErrorFn = 'adodb_test_err';\r
+ $db->Execute('select * from nowhere');\r
+ $rs = $db->Execute('select * from adoxyz');\r
+ $rs->Move(100);\r
+ $rs->_queryID = false;\r
+ $rs->MoveNext();\r
+ $rs = false;\r
+ $conn = NewADOConnection($db->databaseType);\r
+ $conn->raiseErrorFn = 'adodb_test_err';\r
+ @$conn->Connect('abc');\r
+ if ($TESTERRS == 2) print "raiseErrorFn tests passed<br>";\r
+ else print "<b>raiseErrorFn tests failed ($TESTERRS)</b><br>";\r
+?>\r
+ </p>\r
+ <table width=100% ><tr><td bgcolor=beige> </td></tr></table>\r
+ </p></form>\r
+<?php\r
+\r
+ if ($rs1) $rs1->Close();\r
+ if ($rs2) $rs2->Close();\r
+ if ($rs) $rs->Close();\r
+ $db->Close();\r
+}\r
+\r
+function adodb_test_err($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false)\r
+{\r
+global $TESTERRS;\r
+\r
+ $TESTERRS += 1;\r
+ print "<i>** $dbms ($fn): errno=$errno errmsg=$errmsg ($p1,$p2)</i><br>";\r
+ \r
+}\r
+include('./testdatabases.inc.php');\r
+\r
+?>\r
+<p><i>ADODB Database Library (c) 2000-2002 John Lim. All rights reserved. Released under BSD and LGPL.</i></p>\r
+</body>\r
+</html>\r
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\r
+\r
+<html>\r
+<head>\r
+ <title>Untitled</title>\r
+</head>\r
+\r
+<body>\r
+<?php\r
+/*\r
+ V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ Released under both BSD license and Lesser GPL library license. \r
+ Whenever there is any discrepancy between the two licenses, \r
+ the BSD license will take precedence.\r
+ Set tabs to 8.\r
+ */\r
+#\r
+# test connecting to 2 MySQL databases simultaneously and ensure that each connection\r
+# is independant.\r
+#\r
+include("../tohtml.inc.php");\r
+include("../adodb.inc.php"); \r
+\r
+ADOLoadCode('mysql');\r
+\r
+$c1 = ADONewConnection('mysql');\r
+$c2 = ADONewConnection('mysql');\r
+\r
+if (!$c1->PConnect('flipper','','',"test")) \r
+ die("Cannot connect to flipper");\r
+if (!$c2->PConnect('mangrove','root','',"northwind")) \r
+ die("Cannot connect to mangrove");\r
+\r
+print "<h3>Flipper</h3>";\r
+$t = $c1->MetaTables(); # list all tables in DB\r
+print_r($t);\r
+# select * from last table in DB\r
+rs2html($c1->Execute("select * from ".$t[sizeof($t)-1])); \r
+\r
+print "<h3>Mangrove</h3>";\r
+$t = $c2->MetaTables();\r
+print_r($t);\r
+rs2html($c2->Execute("select * from ".$t[sizeof($t)-1] ));\r
+\r
+print "<h3>Flipper</h3>";\r
+$t = $c1->MetaTables();\r
+print_r($t);\r
+rs2html($c1->Execute("select * from ".$t[sizeof($t)-1]));\r
+\r
+?>\r
+\r
+\r
+</body>\r
+</html>\r
--- /dev/null
+<code>\r
+<?php\r
+/*\r
+ V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ Released under both BSD license and Lesser GPL library license. \r
+ Whenever there is any discrepancy between the two licenses, \r
+ the BSD license will take precedence.\r
+ Set tabs to 8.\r
+ */\r
+#\r
+# Code to test Move\r
+#\r
+include("../adodb.inc.php"); \r
+\r
+$c1 = &ADONewConnection('postgres');\r
+if (!$c1->PConnect("susetikus","tester","test","test")) \r
+ die("Cannot connect to database");\r
+\r
+# select * from last table in DB\r
+$rs = $c1->Execute("select * from adoxyz order by 1"); \r
+\r
+$i = 0;\r
+$max = $rs->RecordCount();\r
+if ($max == -1) "RecordCount returns -1<br>";\r
+while (!$rs->EOF and $i < $max) {\r
+ $rs->Move($i);\r
+ print_r( $rs->fields);\r
+ print '<BR>';\r
+ $i++;\r
+}\r
+?>\r
+</code>
\ No newline at end of file
--- /dev/null
+<?php\r
+\r
+/** \r
+ * @version V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ * Released under both BSD license and Lesser GPL library license. \r
+ * Whenever there is any discrepancy between the two licenses, \r
+ * the BSD license will take precedence. \r
+ *\r
+ * Set tabs to 4 for best viewing.\r
+ * \r
+ * Latest version is available at http://php.weblogs.com\r
+ *\r
+ * Test GetUpdateSQL and GetInsertSQL.\r
+ */\r
+ \r
+error_reporting(E_ALL);\r
+function testsql()\r
+{\r
+\r
+include('../adodb.inc.php');\r
+include('../tohtml.inc.php');\r
+\r
+//==========================\r
+// This code tests an insert\r
+\r
+$sql = "SELECT * FROM ADOXYZ WHERE id = -1"; \r
+// Select an empty record from the database \r
+\r
+$conn = &ADONewConnection("mysql"); // create a connection\r
+$conn->debug=1;\r
+$conn->PConnect("localhost", "root", "", "test"); // connect to MySQL, testdb\r
+$conn->Execute("delete from adoxyz where lastname like 'Smith%'");\r
+\r
+$rs = $conn->Execute($sql); // Execute the query and get the empty recordset\r
+$record = array(); // Initialize an array to hold the record data to insert\r
+\r
+// Set the values for the fields in the record\r
+$record["firstname"] = "Bob";\r
+$record["lastname"] = "Smith\$@//";\r
+$record["created"] = time();\r
+\r
+// Pass the empty recordset and the array containing the data to insert\r
+// into the GetInsertSQL function. The function will process the data and return\r
+// a fully formatted insert sql statement.\r
+$insertSQL = $conn->GetInsertSQL($rs, $record);\r
+\r
+$conn->Execute($insertSQL); // Insert the record into the database\r
+\r
+//==========================\r
+// This code tests an update\r
+\r
+$sql = "SELECT * FROM ADOXYZ WHERE lastname=".$conn->qstr($record['lastname']); \r
+// Select a record to update \r
+\r
+$rs = $conn->Execute($sql); // Execute the query and get the existing record to update\r
+if (!$rs) print "<p>No record found!</p>";\r
+$record = array(); // Initialize an array to hold the record data to update\r
+\r
+// Set the values for the fields in the record\r
+$record["firstname"] = "Caroline".rand();\r
+$record["lastname"] = "Smithy"; // Update Caroline's lastname from Miranda to Smith\r
+$record["created"] = '2002-12-'.(rand()%30+1);\r
+\r
+// Pass the single record recordset and the array containing the data to update\r
+// into the GetUpdateSQL function. The function will process the data and return\r
+// a fully formatted update sql statement.\r
+// If the data has not changed, no recordset is returned\r
+$updateSQL = $conn->GetUpdateSQL($rs, $record);\r
+\r
+$conn->Execute($updateSQL); // Update the record in the database\r
+print "<p>Rows Affected=".$conn->Affected_Rows()."</p>";\r
+\r
+rs2html($conn->Execute("select * from adoxyz where lastname like 'Smith%'"));\r
+}\r
+\r
+\r
+testsql();\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+/* \r
+V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ Released under both BSD license and Lesser GPL library license. \r
+ Whenever there is any discrepancy between the two licenses, \r
+ the BSD license will take precedence. \r
+ Set tabs to 4 for best viewing.\r
+ \r
+ Latest version is available at http://php.weblogs.com/\r
+*/\r
+\r
+\r
+// Select an empty record from the database \r
+\r
+include('../adodb.inc.php');\r
+include('../tohtml.inc.php');\r
+\r
+if (0) {\r
+ $conn = &ADONewConnection('mysql');\r
+ $conn->debug=1;\r
+ $conn->PConnect("localhost","root","","xphplens");\r
+ print $conn->databaseType.':'.$conn->GenID().'<br>';\r
+}\r
+\r
+if (0) {\r
+ $conn = &ADONewConnection("oci8"); // create a connection\r
+ $conn->debug=1;\r
+ $conn->PConnect("falcon", "scott", "tiger", "juris8.ecosystem.natsoft.com.my"); // connect to MySQL, testdb\r
+ print $conn->databaseType.':'.$conn->GenID();\r
+}\r
+\r
+if (0) {\r
+ $conn = &ADONewConnection("ibase"); // create a connection\r
+ $conn->debug=1;\r
+ $conn->Connect("localhost:c:\\Interbase\\Examples\\Database\\employee.gdb", "sysdba", "masterkey", ""); // connect to MySQL, testdb\r
+ print $conn->databaseType.':'.$conn->GenID().'<br>';\r
+}\r
+\r
+if (0) {\r
+ $conn = &ADONewConnection('postgres');\r
+ $conn->debug=1;\r
+ @$conn->PConnect("susetikus","tester","test","test");\r
+ print $conn->databaseType.':'.$conn->GenID().'<br>';\r
+}\r
+?>\r
--- /dev/null
+<html>\r
+<body>\r
+<?php\r
+/* \r
+V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ Released under both BSD license and Lesser GPL library license. \r
+ Whenever there is any discrepancy between the two licenses, \r
+ the BSD license will take precedence. \r
+ Set tabs to 4 for best viewing.\r
+ \r
+ Latest version is available at http://php.weblogs.com/\r
+*/\r
+\r
+$ADODB_CACHE_DIR = dirname(tempnam('/tmp',''));\r
+include("../adodb.inc.php");\r
+\r
+if (isset($access)) {\r
+ $db=ADONewConnection('access');\r
+ $db->PConnect('nwind');\r
+} else {\r
+ $db = ADONewConnection('mysql');\r
+ $db->PConnect('mangrove','root','','xphplens');\r
+}\r
+if (isset($cache)) $rs = $db->CacheExecute(120,'select * from products');\r
+else $rs = $db->Execute('select * from products');\r
+\r
+$arr = $rs->GetArray();\r
+print sizeof($arr);\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+ \r
+/*\r
+V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ Released under both BSD license and Lesser GPL library license. \r
+ Whenever there is any discrepancy between the two licenses, \r
+ the BSD license will take precedence.\r
+*/ \r
+ \r
+ /* this file is used by the ADODB test program: test.php */\r
+ \r
+// cannot test databases below, but we include them anyway to check\r
+// if they parse ok...\r
+ADOLoadCode("sybase");\r
+ADOLoadCode("postgres");\r
+ADOLoadCode("postgres7");\r
+ADOLoadCode("firebird");\r
+ADOLoadCode("borland_ibase");\r
+ADOLoadCode("informix");\r
+ADOLoadCode("sqlanywhere");\r
+\r
+if (!empty($testpostgres)) {\r
+ //ADOLoadCode("postgres");\r
+ $db = &ADONewConnection('postgres64');\r
+ print "<h1>Connecting $db->databaseType...</h1>";\r
+ if (@$db->PConnect("susetikus","tester","test","test")) {\r
+ testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname varchar,created date)");\r
+ }else\r
+ print "ERROR: PostgreSQL requires a database called test on server susetikus, user tester, password test.<BR>".$db->ErrorMsg();\r
+}\r
+if (!empty($testibase)) {\r
+ \r
+ $db = &ADONewConnection('ibase');\r
+ print "<h1>Connecting $db->databaseType...</h1>";\r
+ if (@$db->PConnect("localhost:e:\\interbase\\examples\\database\\employee.gdb", "sysdba", "masterkey", ""))\r
+ testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname char(24),created date)");\r
+ else print "ERROR: Interbase test requires a database called employee.gdb".'<BR>'.$db->ErrorMsg();\r
+ \r
+}\r
+\r
+// REQUIRES ODBC DSN CALLED nwind\r
+if (!empty($testaccess)) {\r
+\r
+ $db = &ADONewConnection('access');\r
+ print "<h1>Connecting $db->databaseType...</h1>";\r
+ \r
+ if (@$db->PConnect("nwind", "", "", ""))\r
+ testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");\r
+ else print "ERROR: Access test requires a Windows ODBC DSN=nwind, Access driver";\r
+ \r
+}\r
+\r
+if (!empty($testaccess) && !empty($testado)) { // ADO ACCESS\r
+ \r
+ $db = &ADONewConnection("ado_access");\r
+ print "<h1>Connecting $db->databaseType...</h1>";\r
+ \r
+ $access = 'd:\inetpub\wwwroot\php\NWIND.MDB';\r
+ $myDSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;'\r
+ . 'DATA SOURCE=' . $access . ';';\r
+ //. 'USER ID=;PASSWORD=;';\r
+ \r
+ if (@$db->PConnect($myDSN, "", "", "")) {\r
+ print "ADO version=".$db->_connectionID->version."<br>";\r
+ testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");\r
+ } else print "ERROR: Access test requires a Access database $access".'<BR>'.$db->ErrorMsg();\r
+ \r
+}\r
+\r
+if (!empty($testvfp)) { // ODBC\r
+\r
+ \r
+ $db = &ADONewConnection('vfp');\r
+ print "<h1>Connecting $db->databaseType...</h1>";\r
+ if (@$db->PConnect("logos2", "", "", ""))\r
+ testdb($db,"create table d:\\inetpub\\wwwroot\\logos2\\data\\ADOXYZ (id int, firstname char(24), lastname char(24),created date)");\r
+ else print "ERROR: Visual FoxPro test requires a Windows ODBC DSN=logos2, VFP driver";\r
+ \r
+}\r
+\r
+\r
+// REQUIRES MySQL server at localhost with database 'test'\r
+if (!empty($testmysql)) { // MYSQL\r
+ \r
+ $db = &ADONewConnection('maxsql');\r
+ print "<h1>Connecting $db->databaseType...</h1>";\r
+ if ($HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost';\r
+ else $server = "mangrove";\r
+ if ($db->PConnect($server, "root", "", "test"))\r
+ testdb($db,\r
+ "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) type=innodb");\r
+ else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg();\r
+\r
+ $db = &ADONewConnection('proxy');\r
+ print "<h1>Connecting $db->databaseType...</h1>";\r
+ if ($HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost';\r
+\r
+ if ($db->PConnect('http://localhost/php/phplens/adodb/server.php'))\r
+ testdb($db,\r
+ "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) type=innodb");\r
+ else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg();\r
+\r
+}\r
+\r
+ADOLoadCode('oci805');\r
+ADOLoadCode("oci8po");\r
+if (!empty($testoracle)) { \r
+ \r
+ $db = ADONewConnection();\r
+ print "<h1>Connecting $db->databaseType...</h1>";\r
+ if ($db->Connect('', "scott", "tiger",'natsoft.ecosystem.natsoft.com.my'))\r
+ //if ($db->PConnect("", "scott", "tiger", "juris.ecosystem.natsoft.com.my"))\r
+ testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)");\r
+ else print "ERROR: Oracle test requires an Oracle server setup with scott/tiger".'<BR>'.$db->ErrorMsg();\r
+\r
+}\r
+ADOLoadCode("oracle"); // no longer supported\r
+if (false && !empty($testoracle)) { \r
+ \r
+ $db = ADONewConnection();\r
+ print "<h1>Connecting $db->databaseType...</h1>";\r
+ if ($db->PConnect("", "scott", "tiger", "natsoft.domain"))\r
+ testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)");\r
+ else print "ERROR: Oracle test requires an Oracle server setup with scott/tiger".'<BR>'.$db->ErrorMsg();\r
+\r
+}\r
+\r
+\r
+ADOLoadCode("odbc_mssql");\r
+if (!empty($testmssql) and false) { // MS SQL Server via ODBC\r
+ \r
+ $db = ADONewConnection();\r
+ \r
+ print "<h1>Connecting $db->databaseType...</h1>";\r
+ if (@$db->PConnect("sqlserver", "sa", "natsoft", "")) \r
+ testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");\r
+ else print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN='sqlserver', userid='sa', password='natsoft'";\r
+\r
+}\r
+\r
+ADOLoadCode("ado_mssql");\r
+\r
+if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC -- DSN-less\r
+ \r
+ $db = &ADONewConnection("ado_mssql");\r
+ print "<h1>Connecting DSN-less $db->databaseType...</h1>";\r
+ \r
+ $myDSN="PROVIDER=MSDASQL;DRIVER={SQL Server};"\r
+ . "SERVER=(local);DATABASE=NorthWind;UID=sa;PWD=natsoft;" ;\r
+\r
+ \r
+ if (@$db->PConnect($myDSN, "", "", ""))\r
+ testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");\r
+ else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='mangrove', userid='sa', password='natsoft', database='ai'";\r
+ \r
+}\r
+\r
+\r
+ADOLoadCode("mssql");\r
+if (!empty($testmssql)) { // MS SQL Server -- the extension is buggy -- probably better to use ODBC\r
+ $db = ADONewConnection();\r
+ print "<h1>Connecting $db->databaseType...</h1>";\r
+ \r
+ $db->Connect('(local)\NetSDK','','','northwind');\r
+ \r
+ if (true or @$db->PConnect("mangrove", "sa", "natsoft", "ai")) {\r
+ AutoDetect_MSSQL_Date_Order($db);\r
+ testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");\r
+ } else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='192.168.0.1', userid='sa', password='natsoft', database='ai'".'<BR>'.$db->ErrorMsg();\r
+ \r
+}\r
+\r
+if (!empty($testmssql) && !empty($testado)) { // ADO ACCESS MSSQL with OLEDB provider\r
+\r
+ $db = &ADONewConnection("ado_mssql");\r
+ print "<h1>Connecting DSN-less OLEDB Provider $db->databaseType...</h1>";\r
+ \r
+ $myDSN="SERVER=mangrove;DATABASE=ai;";\r
+ //$myDSN='SERVER=(local)\NetSDK;DATABASE=northwind;';\r
+ if ($db->PConnect($myDSN, "sa", "natsoft", 'SQLOLEDB'))\r
+ testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");\r
+ else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='mangrove', userid='sa', password='', database='ai'";\r
+\r
+}\r
+\r
+\r
+print "<h3>Tests Completed</h3>";\r
+\r
+?>\r
--- /dev/null
+<?php\r
+/*\r
+ Run multiple copies of this php script at the same time\r
+ to test unique generation of id's in multiuser mode\r
+*/\r
+include_once('../adodb.inc.php');\r
+$testaccess = true;\r
+include_once('testdatabases.inc.php');\r
+\r
+function testdb(&$db,$createtab="create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)")\r
+{\r
+ $table = 'adodbseq';\r
+ \r
+ $db->Execute("drop table $table");\r
+ //$db->debug=true;\r
+ \r
+ $ctr = 5000;\r
+ $lastnum = 0;\r
+ \r
+ while (--$ctr >= 0) {\r
+ $num = $db->GenID($table);\r
+ if ($num === false) { \r
+ print "GenID returned false";\r
+ break;\r
+ }\r
+ if ($lastnum + 1 == $num) print " $num ";\r
+ else {\r
+ print " <font color=red>$num</font> ";\r
+ flush();\r
+ }\r
+ $lastnum = $num;\r
+ }\r
+}\r
+?>
\ No newline at end of file
--- /dev/null
+<html>\r
+<body>\r
+<?php\r
+/* \r
+V1.81 22 March 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ Released under both BSD license and Lesser GPL library license. \r
+ Whenever there is any discrepancy between the two licenses, \r
+ the BSD license will take precedence. \r
+ Set tabs to 4 for best viewing.\r
+ \r
+ Latest version is available at http://php.weblogs.com/\r
+*/\r
+error_reporting(63);\r
+include("../adodb.inc.php");\r
+include("../tohtml.inc.php");\r
+\r
+if (1) {\r
+ $db = ADONewConnection('oci8po');\r
+ $db->PConnect('','scott','tiger','natsoftmts');\r
+ $db->debug = true;\r
+\r
+ if (!empty($testblob)) {\r
+ $varHoldingBlob = 'ABC DEF GEF John TEST';\r
+ $num = time()%10240;\r
+ // create table atable (id integer, ablob blob);\r
+ $db->Execute('insert into ATABLE (id,ablob) values('.$num.',empty_blob())');\r
+ $db->UpdateBlob('ATABLE', 'ablob', $varHoldingBlob, 'id='.$num, 'BLOB');\r
+ \r
+ $rs = &$db->Execute('select * from atable');\r
+ \r
+ if (!$rs) die("Empty RS");\r
+ if ($rs->EOF) die("EOF RS");\r
+ rs2html($rs);\r
+ }\r
+ $stmt = $db->Prepare('select * from adoxyz where id=?');\r
+ for ($i = 1; $i <= 10; $i++) {\r
+ $rs = &$db->Execute(\r
+ $stmt,\r
+ array($i));\r
+ \r
+ if (!$rs) die("Empty RS");\r
+ if ($rs->EOF) die("EOF RS");\r
+ rs2html($rs);\r
+ }\r
+}\r
+if (1) {\r
+ $db = ADONewConnection('oci8');\r
+ $db->PConnect('','scott','tiger');\r
+ $db->debug = true;\r
+ $db->Execute("delete from emp where ename='John'");\r
+ print $db->Affected_Rows().'<BR>';\r
+ $stmt = &$db->Prepare('insert into emp (empno, ename) values (:empno, :ename)');\r
+ $rs = $db->Execute($stmt,array('empno'=>4321,'ename'=>'John'));\r
+ // prepare not quite ready for prime time\r
+ //$rs = $db->Execute($stmt,array('empno'=>3775,'ename'=>'John'));\r
+ if (!$rs) die("Empty RS");\r
+}\r
+\r
+if (0) {\r
+ $db = ADONewConnection('odbc_oracle');\r
+ if (!$db->PConnect('local_oracle','scott','tiger')) die('fail connect');\r
+ $db->debug = true;\r
+ $rs = &$db->Execute(\r
+ 'select * from adoxyz where firstname=? and trim(lastname)=?',\r
+ array('first'=>'Caroline','last'=>'Miranda'));\r
+ if (!$rs) die("Empty RS");\r
+ if ($rs->EOF) die("EOF RS");\r
+ rs2html($rs);\r
+}\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+/* \r
+V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ Released under both BSD license and Lesser GPL library license. \r
+ Whenever there is any discrepancy between the two licenses, \r
+ the BSD license will take precedence. \r
+ Set tabs to 4 for best viewing.\r
+ \r
+ Latest version is available at http://php.weblogs.com/\r
+*/\r
+\r
+error_reporting(E_ALL);\r
+\r
+$PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];\r
+\r
+include_once('../adodb-pear.inc.php');\r
+include_once('../tohtml.inc.php');\r
+session_register('curr_page');\r
+\r
+$db = NewADOConnection('mysql');\r
+$db->debug = true;\r
+//$db->Connect('localhost:4321','scott','tiger','natsoft.domain');\r
+$db->Connect('localhost','root','','xphplens');\r
+\r
+$num_of_rows_per_page = 7;\r
+$sql = "select * from adoxyz ";\r
+\r
+if (isset($HTTP_GET_VARS['next_page']))\r
+ $curr_page = $HTTP_GET_VARS['next_page'];\r
+if (empty($curr_page)) $curr_page = 1; ## at first page\r
+\r
+$rs = $db->PageExecute($sql, $num_of_rows_per_page, $curr_page);\r
+if (!$rs) die('Query Failed');\r
+\r
+if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage())) {\r
+ if (!$rs->AtFirstPage()) {\r
+?>\r
+<a href="<?php echo $PHP_SELF;?>?next_page=1">First page</a> \r
+<a href="<?php echo $PHP_SELF,'?next_page=',$rs->AbsolutePage() - 1 ?>">Previous page</a> \r
+<?php\r
+ } else {\r
+ echo " First Page Previous Page ";\r
+ }\r
+ if (!$rs->AtLastPage()) {\r
+?>\r
+<a href="<?php echo $PHP_SELF,'?next_page=',$rs->AbsolutePage() + 1 ?>">Next Page</a>\r
+<?php\r
+ } else\r
+ print "Next Page";\r
+ rs2html($rs);\r
+}\r
+\r
+\r
+?>\r
--- /dev/null
+<?php\r
+/* \r
+V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ Released under both BSD license and Lesser GPL library license. \r
+ Whenever there is any discrepancy between the two licenses, \r
+ the BSD license will take precedence. \r
+ Set tabs to 4 for best viewing.\r
+ \r
+ Latest version is available at http://php.weblogs.com/\r
+*/\r
+\r
+error_reporting(E_ALL);\r
+\r
+include_once('../adodb-pear.inc.php');\r
+$username = 'root';\r
+$password = '';\r
+$hostname = 'localhost';\r
+$databasename = 'xphplens';\r
+$driver = 'mysql';\r
+\r
+$dsn = "$driver://$username:$password@$hostname/$databasename";\r
+\r
+$db = DB::Connect($dsn);\r
+$db->setFetchMode(ADODB_FETCH_ASSOC);\r
+$rs = $db->Query('select firstname,lastname from adoxyz');\r
+$cnt = 0;\r
+while ($arr = $rs->FetchRow()) {\r
+ print_r($arr);\r
+ print "<br>";\r
+ $cnt += 1;\r
+}\r
+\r
+if ($cnt != 50) print "<b>Error in \$cnt = $cnt</b>";\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+/* \r
+V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ Released under both BSD license and Lesser GPL library license. \r
+ Whenever there is any discrepancy between the two licenses, \r
+ the BSD license will take precedence. \r
+ Set tabs to 4 for best viewing.\r
+ \r
+ Latest version is available at http://php.weblogs.com/\r
+*/\r
+\r
+GLOBAL $HTTP_SESSION_VARS;\r
+\r
+ $ADODB_SESS_DEBUG = true;\r
+ include('adodb.inc.php');\r
+ include('adodb-session.php');\r
+ session_start();\r
+ session_register('AVAR');\r
+ $HTTP_SESSION_VARS['AVAR'] += 1;\r
+ $AVAR += 1;\r
+ \r
+ print "<p>\$HTTP_SESSION_VARS['AVAR']={$HTTP_SESSION_VARS['AVAR']}</p>";\r
+ \r
+?>
\ No newline at end of file