From 9fa730a60bde0d4fab130e0ff061566a01de137e Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 17 May 2002 13:20:16 +0000 Subject: [PATCH] Upgraded ADOdb to 2.00 --- lib/adodb/tests/benchmark.php | 85 +++ lib/adodb/tests/client.php | 194 +++++++ lib/adodb/tests/test.php | 755 ++++++++++++++++++++++++++ lib/adodb/tests/test2.php | 54 ++ lib/adodb/tests/test3.php | 32 ++ lib/adodb/tests/test4.php | 78 +++ lib/adodb/tests/test5.php | 45 ++ lib/adodb/tests/testcache.php | 29 + lib/adodb/tests/testdatabases.inc.php | 189 +++++++ lib/adodb/tests/testgenid.php | 34 ++ lib/adodb/tests/testoci8.php | 70 +++ lib/adodb/tests/testpaging.php | 54 ++ lib/adodb/tests/testpear.php | 34 ++ lib/adodb/tests/testsessions.php | 24 + 14 files changed, 1677 insertions(+) create mode 100644 lib/adodb/tests/benchmark.php create mode 100644 lib/adodb/tests/client.php create mode 100644 lib/adodb/tests/test.php create mode 100644 lib/adodb/tests/test2.php create mode 100644 lib/adodb/tests/test3.php create mode 100644 lib/adodb/tests/test4.php create mode 100644 lib/adodb/tests/test5.php create mode 100644 lib/adodb/tests/testcache.php create mode 100644 lib/adodb/tests/testdatabases.inc.php create mode 100644 lib/adodb/tests/testgenid.php create mode 100644 lib/adodb/tests/testoci8.php create mode 100644 lib/adodb/tests/testpaging.php create mode 100644 lib/adodb/tests/testpear.php create mode 100644 lib/adodb/tests/testsessions.php diff --git a/lib/adodb/tests/benchmark.php b/lib/adodb/tests/benchmark.php new file mode 100644 index 00000000000..32002ede0b7 --- /dev/null +++ b/lib/adodb/tests/benchmark.php @@ -0,0 +1,85 @@ + + + + + ADODB Benchmarks + + + +ADODB Version: $ADODB_version Host: $db->host   Database: $db->database"; + + // perform query once to cache results so we are only testing throughput + $rs = $db->Execute($sql); + if (!$rs){ + print "Error in recordset

"; + return; + } + $arr = $rs->GetArray(); + //$db->debug = true; + + $start = microtime(); + for ($i=0; $i < $max; $i++) { + $rs = $db->Execute($sql); + $arr = $rs->GetArray(); + // print $arr[0][1]; + } + $end = microtime(); + $start = explode(' ',$start); + $end = explode(' ',$end); + + print_r($start); + print_r($end); + + // print_r($arr); + $total = $end[0]+trim($end[1]) - $start[0]-trim($start[1]); + printf ("

seconds = %8.2f for %d iterations each with %d records

",$total,$max, sizeof($arr)); + flush(); + +?> +

+
 
+

+Close(); +} +include("testdatabases.inc.php"); + +?> + + + + diff --git a/lib/adodb/tests/client.php b/lib/adodb/tests/client.php new file mode 100644 index 00000000000..55b39e821f0 --- /dev/null +++ b/lib/adodb/tests/client.php @@ -0,0 +1,194 @@ + + +$url

"; + $rs = csv2rs($url,$err); + if ($err) print $err; + return $rs; + } + + function print_pre($s) + { + print "
";print_r($s);print "
"; + } + + +$serverURL = 'http://localhost/php/phplens/adodb/server.php'; +$testhttp = false; + +$sql1 = "insertz into products (productname) values ('testprod 1')"; +$sql2 = "insert into products (productname) values ('testprod 1')"; +$sql3 = "insert into products (productname) values ('testprod 2')"; +$sql4 = "delete from products where productid>80"; +$sql5 = 'select * from products'; + +if ($testhttp) { + print "Client Driver Tests

"; + print "

Test Error

"; + $rs = send2server($serverURL,$sql1); + print_pre($rs); + print "
"; + + print "

Test Insert

"; + + $rs = send2server($serverURL,$sql2); + print_pre($rs); + print "
"; + + print "

Test Insert2

"; + + $rs = send2server($serverURL,$sql3); + print_pre($rs); + print "
"; + + print "

Test Delete

"; + + $rs = send2server($serverURL,$sql4); + print_pre($rs); + print "
"; + + + print "

Test Select

"; + $rs = send2server($serverURL,$sql5); + if ($rs) rs2html($rs); + + print "
"; +} + + +print "

CLIENT Driver Tests

"; +$conn = ADONewConnection('csv'); +$conn->Connect($serverURL); +$conn->debug = true; + +print "

Bad SQL

"; + +$rs = $conn->Execute($sql1); + +print "

Insert SQL 1

"; +$rs = $conn->Execute($sql2); + +print "

Insert SQL 2

"; +$rs = $conn->Execute($sql3); + +print "

Select SQL

"; +$rs = $conn->Execute($sql5); +if ($rs) rs2html($rs); + +print "

Delete SQL

"; +$rs = $conn->Execute($sql4); + +print "

Select SQL

"; +$rs = $conn->Execute($sql5); +if ($rs) rs2html($rs); + + +/* EXPECTED RESULTS FOR HTTP TEST: + +Test Insert +http://localhost/php/adodb/server.php?sql=insert+into+products+%28productname%29+values+%28%27testprod%27%29 + +adorecordset Object +( + [dataProvider] => native + [fields] => + [blobSize] => 64 + [canSeek] => + [EOF] => 1 + [emptyTimeStamp] => + [emptyDate] => + [debug] => + [timeToLive] => 0 + [bind] => + [_numOfRows] => -1 + [_numOfFields] => 0 + [_queryID] => 1 + [_currentRow] => -1 + [_closed] => + [_inited] => + [sql] => insert into products (productname) values ('testprod') + [affectedrows] => 1 + [insertid] => 81 +) + + +-------------------------------------------------------------------------------- + +Test Insert2 +http://localhost/php/adodb/server.php?sql=insert+into+products+%28productname%29+values+%28%27testprod%27%29 + +adorecordset Object +( + [dataProvider] => native + [fields] => + [blobSize] => 64 + [canSeek] => + [EOF] => 1 + [emptyTimeStamp] => + [emptyDate] => + [debug] => + [timeToLive] => 0 + [bind] => + [_numOfRows] => -1 + [_numOfFields] => 0 + [_queryID] => 1 + [_currentRow] => -1 + [_closed] => + [_inited] => + [sql] => insert into products (productname) values ('testprod') + [affectedrows] => 1 + [insertid] => 82 +) + + +-------------------------------------------------------------------------------- + +Test Delete +http://localhost/php/adodb/server.php?sql=delete+from+products+where+productid%3E80 + +adorecordset Object +( + [dataProvider] => native + [fields] => + [blobSize] => 64 + [canSeek] => + [EOF] => 1 + [emptyTimeStamp] => + [emptyDate] => + [debug] => + [timeToLive] => 0 + [bind] => + [_numOfRows] => -1 + [_numOfFields] => 0 + [_queryID] => 1 + [_currentRow] => -1 + [_closed] => + [_inited] => + [sql] => delete from products where productid>80 + [affectedrows] => 2 + [insertid] => 0 +) + +[more stuff deleted] + . + . + . +*/ +?> diff --git a/lib/adodb/tests/test.php b/lib/adodb/tests/test.php new file mode 100644 index 00000000000..a0eb27bbc92 --- /dev/null +++ b/lib/adodb/tests/test.php @@ -0,0 +1,755 @@ +$v) { + global $$k; + + $$k = $v; +} + +if (sizeof($HTTP_GET_VARS) == 0) $testmysql = true; +?> + +ADODB Testing + +

ADODB Test

+ +This script tests the following databases: Interbase, Oracle, Visual FoxPro, Microsoft Access (ODBC and ADO), MySQL, MSSQL (ODBC, native, ADO). +There is also support for Sybase, PostgreSQL.

+For the latest version of ADODB, visit
php.weblogs.com.

+ +
+> Access
+> Interbase
+> MSSQL
+ > MySQL
+> Oracle (oci8)
+> PostgreSQL
+> VFP
+> ADO (for mssql and access)
+ +
+ +Test GetInsertSQL/GetUpdateSQL   + Sessions   + Paging   +FETCH MODE IS NOT ADODB_FETCH_DEFAULT"; + +// the table creation code is specific to the database, so we allow the user +// to define their own table creation stuff +function testdb(&$db,$createtab="create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)") +{ +GLOBAL $ADODB_vers,$ADODB_CACHE_DIR,$ADODB_FETCH_MODE, $HTTP_GET_VARS,$ADODB_COUNTRECS; +?>
+

+
 
+

+debug = false; + + $phpv = phpversion(); + print "

ADODB Version: $ADODB_vers Host: $db->host   Database: $db->database   PHP: $phpv

"; + $e = error_reporting(E_ALL-E_WARNING); + + + print "date1 (1999-02-20) = ".$db->DBDate('1999-2-20'); + print "
date2 (1970-1-2) = ".$db->DBDate(24*3600)."

"; + print "ts1 (1999-02-20 3:40:50) = ".$db->DBTimeStamp('1999-2-20 3:40:50'); + print "
ts2 (1999-02-20) = ".$db->DBTimeStamp('1999-2-20'); + print "
ts3 (1970-1-2 +/- timezone) = ".$db->DBTimeStamp(24*3600); + $dd = $db->UnixDate('1999-02-20'); + print "
unixdate 1999-02-20 = ".date('Y-m-d',$dd)."

"; + // mssql too slow in failing bad connection + if ($db->databaseType != 'mssql') { + print "

Testing bad connection. Ignore following error msgs:
"; + $db2 = ADONewConnection(); + $rez = $db2->Connect("bad connection"); + $err = $db2->ErrorMsg(); + print "Error='$err'

"; + if ($rez) print "Cannot check if connection failed. The Connect() function returned true.

"; + } + error_reporting($e); + + //$ADODB_COUNTRECS=false; + $rs=$db->Execute('select * from adoxyz order by id'); + //print_r($rs); + //OCIFetchStatement($rs->_queryID,$rez,0,-1);//,OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW); + //print_r($rez); + //die(); + if($rs === false) $create = true; + else $rs->Close(); + + //if ($db->databaseType !='vfp') $db->Execute("drop table ADOXYZ"); + + if ($create) { + if ($db->databaseType == 'ibase') { + print "Please create the following table for testing:

$createtab

"; + return; + } else { + $db->debug = 1; + $e = error_reporting(E_ALL-E_WARNING); + $db->Execute($createtab); + error_reporting($e); + } + } + + $rs = &$db->Execute("delete from ADOXYZ"); // some ODBC drivers will fail the drop so we delete + if ($rs) { + if(! $rs->EOF)print "Error: RecordSet returned by Execute('delete...') should show EOF

"; + $rs->Close(); + } else print "err=".$db->ErrorMsg(); + + print "

Test select on empty table

"; + $rs = &$db->Execute("select * from ADOXYZ where id=9999"); + if ($rs && !$rs->EOF) print "Error: RecordSet returned by Execute(select...') on empty table should show EOF

"; + if ($rs) $rs->Close(); + + + $db->debug=false; + print "

Testing Commit: "; + $time = $db->DBDate(time()); + if (!$db->BeginTrans()) print 'Transactions not supported

'; + else { /* COMMIT */ + $rs = $db->Execute("insert into ADOXYZ values (99,'Should Not','Exist (Commit)',$time)"); + if ($rs && $db->CommitTrans()) { + $rs->Close(); + $rs = &$db->Execute("select * from ADOXYZ where id=99"); + if ($rs === false || $rs->EOF) { + print 'Data not saved

'; + $rs = &$db->Execute("select * from ADOXYZ where id=99"); + print_r($rs); + die(); + } else print 'OK

'; + if ($rs) $rs->Close(); + } else + print "Commit failed

"; + + /* ROLLBACK */ + if (!$db->BeginTrans()) print "

Error in BeginTrans()

"; + print "

Testing Rollback: "; + $db->Execute("insert into ADOXYZ values (100,'Should Not','Exist (Rollback)',$time)"); + if ($db->RollbackTrans()) { + $rs = $db->Execute("select * from ADOXYZ where id=100"); + if ($rs && !$rs->EOF) print 'Fail: Data should rollback

'; + else print 'OK

'; + if ($rs) $rs->Close(); + } else + print "Commit failed

"; + + $rs = &$db->Execute('delete from ADOXYZ where id>50'); + if ($rs) $rs->Close(); + } + + if (1) { + print "

Testing MetaDatabases()

"; + print_r( $db->MetaDatabases()); + + print "

Testing MetaTables() and MetaColumns()

"; + $a = $db->MetaTables(); + if ($a===false) print "MetaTables not supported

"; + else { + print "Array of tables: "; + foreach($a as $v) print " ($v) "; + print '

'; + } + $a = $db->MetaColumns('ADOXYZ'); + if ($a===false) print "MetaColumns not supported

"; + else { + print "

Columns of ADOXYZ: "; + foreach($a as $v) print " ($v->name $v->type $v->max_length) "; + } + } + $rs = &$db->Execute('delete from ADOXYZ'); + if ($rs) $rs->Close(); + + $db->debug = false; + + if ($db->databaseType == 'mssql') { +/* +ASSUME Northwind available... + +CREATE PROCEDURE SalesByCategory + @CategoryName nvarchar(15), @OrdYear nvarchar(4) = '1998' +AS +IF @OrdYear != '1996' AND @OrdYear != '1997' AND @OrdYear != '1998' +BEGIN + SELECT @OrdYear = '1998' +END + +SELECT ProductName, + TotalPurchase=ROUND(SUM(CONVERT(decimal(14,2), OD.Quantity * (1-OD.Discount) * OD.UnitPrice)), 0) +FROM [Order Details] OD, Orders O, Products P, Categories C +WHERE OD.OrderID = O.OrderID + AND OD.ProductID = P.ProductID + AND P.CategoryID = C.CategoryID + AND C.CategoryName = @CategoryName + AND SUBSTRING(CONVERT(nvarchar(22), O.OrderDate, 111), 1, 4) = @OrdYear +GROUP BY ProductName +ORDER BY ProductName +GO +*/ + print "

Testing Stored Procedures for mssql

"; + $saved = $db->debug; + $db->debug=true; + + $cat = 'Dairy Products'; + $yr = '1998'; + + $stmt = $db->PrepareSP('SalesByCategory'); + $db->Parameter($stmt,$cat,'CategoryName'); + $db->Parameter($stmt,$yr,'OrdYear'); + $rs = $db->Execute($stmt); + rs2html($rs); + + $cat = 'Grains/Cereals'; + $yr = 1998; + + $stmt = $db->PrepareSP('SalesByCategory'); + $db->Parameter($stmt,$cat,'CategoryName'); + $db->Parameter($stmt,$yr,'OrdYear'); + $rs = $db->Execute($stmt); + rs2html($rs); + + $db->debug = $saved; + } else if (substr($db->databaseType,0,4) == 'oci8') { + print "

Testing Stored Procedures for oci8

"; + $saved = $db->debug; + $db->debug=true; + + $tname = 'A%'; + + $stmt = $db->PrepareSP('select * from tab where tname like :tablename'); + $db->Parameter($stmt,$tname,'tablename'); + $rs = $db->Execute($stmt); + rs2html($rs); + + $db->debug = $saved; + } + print "

Inserting 50 rows

"; + + for ($i = 0; $i < 5; $i++) { + + $time = $db->DBDate(time()); + if (empty($HTTP_GET_VARS['hide'])) $db->debug = true; + switch($db->databaseType){ + default: + $arr = array(0=>'Caroline',1=>'Miranda'); + $sql = "insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+0,?,?,$time)"; + break; + case 'oci8': + case 'oci805': + $arr = array('first'=>'Caroline','last'=>'Miranda'); + $sql = "insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+0,:first,:last,$time)"; + break; + } + if ($i & 1) { + $sql = $db->Prepare($sql); + } + $rs = $db->Execute($sql,$arr); + + if ($rs === false) print 'Error inserting with parameters
'; + else $rs->Close(); + + $db->debug = false; + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+1,'John','Lim',$time)"); + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+2,'Mary','Lamb',$time )"); + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+3,'George','Washington',$time )"); + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+4,'Mr. Alan','Tam',$time )"); + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+5,'Alan','Turing',$time )"); + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created)values ($i*10+6,'Serena','Williams',$time )"); + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+7,'Yat Sun','Sun',$time )"); + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+8,'Wai Hun','See',$time )"); + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+9,'Steven','Oey',$time )"); + } + + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + + $db->Execute('update ADOXYZ set id=id+1'); + $nrows = $db->Affected_Rows(); + if ($nrows === false) print "

Affected_Rows() not supported

"; + else if ($nrows != 50) print "

Affected_Rows() Error: $nrows returned (should be 50)

"; + else print "

Affected_Rows() passed

"; + $db->debug = false; + + $ADODB_FETCH_MODE = ADODB_FETCH_BOTH; + /////////////////////////////// + + $rs = &$db->Execute("select * from ADOXYZ order by id"); + if ($rs) { + // print_r($rs); + if ($rs->RecordCount() != 50) { + print "

RecordCount returns -1

"; + if ($rs->PO_RecordCount('ADOXYZ') == 50) print "

    PO_RecordCount passed

"; + else print "

PO_RecordCount returns wrong value

"; + } else print "

RecordCount() passed

"; + if (isset($rs->fields['firstname'])) print '

The fields columns can be indexed by column name.

'; + else print '

The fields columns cannot be indexed by column name.

'; + if (empty($HTTP_GET_VARS['hide'])) rs2html($rs); + } + else print "Error in Execute of SELECT

"; + + $val = $db->GetOne("select count(*) from ADOXYZ"); + if ($val == 50) print "

GetOne returns ok

"; + else print "

Fail: GetOne returns $val

"; + + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $val = $db->GetRow("select count(*) from ADOXYZ"); + if ($val[0] == 50 and sizeof($val) == 1) print "

GetRow returns ok

"; + else { + print_r($val); + print "

Fail: GetRow returns {$val[0]}

"; + } + + print "

FetchObject/FetchNextObject Test

"; + $rs = &$db->Execute('select * from ADOXYZ'); + if (empty($rs->connection)) print "Connection object missing from recordset
"; + + while ($o = $rs->FetchNextObject()) { // calls FetchObject internally + if (!is_string($o->FIRSTNAME) || !is_string($o->LASTNAME)) { + print_r($o); + print "

Firstname is not string

"; + break; + } + } + + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + print "

FetchObject/FetchNextObject Test 2

"; + $rs = &$db->Execute('select * from ADOXYZ'); + if (empty($rs->connection)) print "Connection object missing from recordset
"; + + while ($o = $rs->FetchNextObject()) { // calls FetchObject internally + if (!is_string($o->FIRSTNAME) || !is_string($o->LASTNAME)) { + print_r($o); + print "

Firstname is not string

"; + break; + } + } + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + + $savefetch = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + + print "

CacheSelectLimit Test

"; + $rs = $db->CacheSelectLimit('select id, firstname from ADOXYZ order by id',2); + if ($rs && !$rs->EOF) { + if ($rs->fields['id'] != 1) {print "Error 1
"; print_r($rs->fields);}; + if (trim($rs->fields['firstname']) != 'Caroline') {print "Error 2
"; print_r($rs->fields);}; + $rs->MoveNext(); + if ($rs->fields['id'] != 2) {print "Error 3
"; print_r($rs->fields);}; + $rs->MoveNext(); + if (!$rs->EOF) print "EOF Error
"; + } + + print "

FETCH_MODE = ASSOC: Should get 1, Caroline

"; + $rs = &$db->SelectLimit('select id,firstname from ADOXYZ order by id',2); + if ($rs && !$rs->EOF) { + if ($rs->fields['id'] != 1) {print "Error 1
"; print_r($rs->fields);}; + if (trim($rs->fields['firstname']) != 'Caroline') {print "Error 2
"; print_r($rs->fields);}; + $rs->MoveNext(); + if ($rs->fields['id'] != 2) {print "Error 3
"; print_r($rs->fields);}; + $rs->MoveNext(); + if (!$rs->EOF) print "EOF Error
"; + } + + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + print "

FETCH_MODE = NUM: Should get 1, Caroline

"; + $rs = &$db->SelectLimit('select id,firstname from ADOXYZ order by id',1); + if ($rs && !$rs->EOF) { + if ($rs->fields[0] != 1) {print "Error 1
"; print_r($rs->fields);}; + if (trim($rs->fields[1]) != 'Caroline') {print "Error 2
"; print_r($rs->fields);}; + $rs->MoveNext(); + if (!$rs->EOF) print "EOF Error
"; + + } + $ADODB_FETCH_MODE = $savefetch; + + $db->debug = false; + print "

GetRowAssoc Upper: Should get 1, Caroline

"; + $rs = &$db->SelectLimit('select id,firstname from ADOXYZ order by id',1); + if ($rs && !$rs->EOF) { + $arr = &$rs->GetRowAssoc(); + if ($arr['ID'] != 1) {print "Error 1
"; print_r($arr);}; + if (trim($arr['FIRSTNAME']) != 'Caroline') {print "Error 2
"; print_r($arr);}; + $rs->MoveNext(); + if (!$rs->EOF) print "EOF Error
"; + + } + print "

GetRowAssoc Lower: Should get 1, Caroline

"; + $rs = &$db->SelectLimit('select id,firstname from ADOXYZ order by id',1); + if ($rs && !$rs->EOF) { + $arr = &$rs->GetRowAssoc(false); + if ($arr['id'] != 1) {print "Error 1
"; print_r($arr);}; + if (trim($arr['firstname']) != 'Caroline') {print "Error 2
"; print_r($arr);}; + + } + //$db->debug = true; + print "

SelectLimit Test 1: Should see Caroline, John and Mary

"; + $rs = &$db->SelectLimit('select distinct * from ADOXYZ order by id',3); + if ($rs && !$rs->EOF) { + if (trim($rs->fields[1]) != 'Caroline') print "Error 1
"; + $rs->MoveNext(); + if (trim($rs->fields[1]) != 'John') print "Error 2
"; + $rs->MoveNext(); + if (trim($rs->fields[1]) != 'Mary') print "Error 3
"; + $rs->MoveNext(); + if (! $rs->EOF) print "Not EOF
"; + //rs2html($rs); + } + else "

Failed SelectLimit Test 1

"; + print "

SelectLimit Test 2: Should see Mary, George and Mr. Alan

"; + $rs = &$db->SelectLimit('select * from ADOXYZ order by id',3,2); + if ($rs && !$rs->EOF) { + if (trim($rs->fields[1]) != 'Mary') print "Error 1
"; + $rs->MoveNext(); + if (trim($rs->fields[1]) != 'George') print "Error 2
"; + $rs->MoveNext(); + if (trim($rs->fields[1]) != 'Mr. Alan') print "Error 3
"; + $rs->MoveNext(); + if (! $rs->EOF) print "Not EOF
"; + // rs2html($rs); + } + else "

Failed SelectLimit Test 2

"; + + print "

SelectLimit Test 3: Should see Wai Hun and Steven

"; + $rs = &$db->SelectLimit('select * from ADOXYZ order by id',-1,48); + if ($rs && !$rs->EOF) { + if (empty($rs->connection)) print "Connection object missing from recordset
"; + if (trim($rs->fields[1]) != 'Wai Hun') print "Error 1
"; + $rs->MoveNext(); + if (trim($rs->fields[1]) != 'Steven') print "Error 2
"; + $rs->MoveNext(); + if (! $rs->EOF) print "Not EOF
"; + //rs2html($rs); + } + else "

Failed SelectLimit Test 3

"; + $db->debug = false; + + $rs = &$db->Execute("select * from ADOXYZ order by id"); + print "

Testing Move()

"; + if (!$rs)print "Failed Move SELECT

"; + else { + if (!$rs->Move(2)) { + if (!$rs->canSeek) print "

$db->databaseType: Move(), MoveFirst() nor MoveLast() not supported.

"; + else print '

RecordSet->canSeek property should be set to false

'; + } else { + $rs->MoveFirst(); + if (trim($rs->Fields("firstname")) != 'Caroline') { + print "

$db->databaseType: MoveFirst failed -- probably cannot scroll backwards

"; + } + else print "MoveFirst() OK
"; + + // Move(3) tests error handling -- MoveFirst should not move cursor + $rs->Move(3); + if (trim($rs->Fields("firstname")) != 'George') { + print '

'.$rs->Fields("id")."$db->databaseType: Move(3) failed

"; + print_r($rs); + } else print "Move(3) OK
"; + + $rs->Move(7); + if (trim($rs->Fields("firstname")) != 'Yat Sun') { + print '

'.$rs->Fields("id")."$db->databaseType: Move(7) failed

"; + print_r($rs); + } else print "Move(7) OK
"; + + $rs->MoveLast(); + if (trim($rs->Fields("firstname")) != 'Steven'){ + print '

'.$rs->Fields("id")."$db->databaseType: MoveLast() failed

"; + print_r($rs); + }else print "MoveLast() OK
"; + } + } + + // $db->debug=true; + print "

Testing ADODB_FETCH_ASSOC and concat: concat firstname and lastname

"; + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + if ($db->dataProvider == 'postgres') + $rs = &$db->Execute("select distinct ".$db->Concat('(firstname',$db->qstr(' ').')','lastname').",id from ADOXYZ"); + else + $rs = &$db->Execute("select distinct ".$db->Concat('firstname',$db->qstr(' '),'lastname').",id from ADOXYZ"); + if ($rs) { + if (empty($HTTP_GET_VARS['hide'])) rs2html($rs); + } else print "Failed Concat

"; + + $ADODB_FETCH_MODE = $save; + print "
Testing GetArray() "; + $rs = &$db->Execute("select * from ADOXYZ order by id"); + if ($rs) { + $arr = &$rs->GetArray(10); + if (sizeof($arr) != 10 || trim($arr[1][1]) != 'John' || trim($arr[1][2]) != 'Lim') print $arr[1][1].' '.$arr[1][2]."   ERROR
"; + else print " OK
"; + } + + print "Testing FetchNextObject for 1 object "; + $rs = &$db->Execute("select distinct lastname,firstname from ADOXYZ where firstname='Caroline'"); + $fcnt = 0; + if ($rs) + while ($o = $rs->FetchNextObject()) { + $fcnt += 1; + } + if ($fcnt == 1) print " OK
"; + else print "FAILED
"; + + print "Testing GetAssoc() "; + $rs = &$db->Execute("select distinct lastname,firstname from ADOXYZ"); + if ($rs) { + $arr = $rs->GetAssoc(); + if (trim($arr['See']) != 'Wai Hun') print $arr['See']."   ERROR
"; + else print " OK
"; + } + + for ($loop=0; $loop < 1; $loop++) { + print "Testing GetMenu() and CacheExecute
"; + $db->debug = true; + $rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ"); + if ($rs) print 'With blanks, Steven selected:'. $rs->GetMenu('menu','Steven').'
'; + else print " Fail
"; + $rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ"); + if ($rs) print ' No blanks, Steven selected: '. $rs->GetMenu('menu','Steven',false).'
'; + else print " Fail
"; + + $rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ"); + if ($rs) print ' Multiple, Alan selected: '. $rs->GetMenu('menu','Alan',false,true).'
'; + else print " Fail
"; + print '


'; + + $rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ"); + if ($rs) { + print ' Multiple, Alan and George selected: '. $rs->GetMenu('menu',array('Alan','George'),false,true); + if (empty($rs->connection)) print "Connection object missing from recordset
"; + } else print " Fail
"; + print '


'; + + print "Testing GetMenu2()
"; + $rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ"); + if ($rs) print 'With blanks, Steven selected:'. $rs->GetMenu2('menu',('Oey')).'
'; + else print " Fail
"; + $rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ"); + if ($rs) print ' No blanks, Steven selected: '. $rs->GetMenu2('menu',('Oey'),false).'
'; + else print " Fail
"; + } + + $db->debug = false; + $rs1 = &$db->Execute("select id from ADOXYZ where id = 2 or id = 1 order by 1"); + $rs2 = &$db->Execute("select id from ADOXYZ where id = 3 or id = 4 order by 1"); + + if ($rs1) $rs1->MoveLast(); + if ($rs2) $rs2->MoveLast(); + + if (empty($rs1) || empty($rs2) || $rs1->fields[0] != 2 || $rs2->fields[0] != 4) { + $a = $rs1->fields[0]; + $b = $rs2->fields[0]; + print "

Error in multiple recordset test rs1=$a rs2=%b (should be rs1=2 rs2=4)

"; + } else + print "

Testing multiple recordsets OK

"; + + + echo "

GenID test: "; + for ($i=1; $i <= 10; $i++) + echo "($i: ",$val = $db->GenID('abcseq5' ,5), ") "; + if ($val == 0) echo "

GenID not supported"; + echo "

"; + + if (substr($db->dataProvider,0,3) != 'ado') { // crashes ado + $sql = "select firstnames from adoxyz"; + print "

Testing execution of illegal statement: $sql

"; + if ($db->Execute($sql) === false) { + print "

This returns the following ErrorMsg(): ".$db->ErrorMsg()." and ErrorNo(): ".$db->ErrorNo().'

'; + } else + print "

Error in error handling -- Execute() should return false

"; + } else + print "

ADO skipped error handling of bad select statement

"; + + print "

ASSOC TEST 2
"; + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + $rs = $db->query('select * from adoxyz order by id'); + for($i=0;$i<$rs->FieldCount();$i++) + { + $fld=$rs->FetchField($i); + print "
Field name is ".$fld->name; + print " ".$rs->Fields($fld->name); + } + + + print "

BOTH TEST 2
"; + if ($db->dataProvider == 'ado') { + print "ADODB_FETCH_BOTH not supported for dataProvider=".$db->dataProvider."
"; + } else { + $ADODB_FETCH_MODE = ADODB_FETCH_BOTH; + $rs = $db->query('select * from adoxyz order by id'); + for($i=0;$i<$rs->FieldCount();$i++) + { + $fld=$rs->FetchField($i); + print "
Field name is ".$fld->name; + print " ".$rs->Fields($fld->name); + } + } + + print "

NUM TEST 2
"; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $rs = $db->query('select * from adoxyz order by id'); + for($i=0;$i<$rs->FieldCount();$i++) + { + $fld=$rs->FetchField($i); + print "
Field name is ".$fld->name; + print " ".$rs->Fields($fld->name); + } + + print "

ASSOC Test of SelectLimit
"; + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + $rs = $db->selectlimit('select * from adoxyz order by id',3,4); + $cnt = 0; + while ($rs && !$rs->EOF) { + $cnt += 1; + if (!isset($rs->fields['firstname'])) { + print "
ASSOC returned numeric field

"; + break; + } + $rs->MoveNext(); + } + if ($cnt != 3) print "
Count should be 3, instead it was $cnt

"; + + + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($db->sysDate) { + $saved = $db->debug; + $db->debug = 1; + $rs = $db->Execute("select {$db->sysDate} from adoxyz where id=1"); + if (ADORecordSet::UnixDate(date('Y-m-d')) != $rs->UnixDate($rs->fields[0])) { + print "

Invalid date {$rs->fields[0]}

"; + } else + print "

Passed \$sysDate test ({$rs->fields[0]})

"; + + $db->debug=$saved; + } else { + print "

\$db->sysDate not defined

"; + } + // PEAR TESTS BELOW + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $pear = true; + $rs = $db->query('select * from adoxyz order by id'); + + $i = 0; + if ($rs && !$rs->EOF) { + while ($arr = $rs->fetchRow()) { + $i++; + //print "$i "; + if ($arr[0] != $i) { + print "

PEAR DB emulation error 1.

"; + $pear = false; + break; + } + } + $rs->Close(); + } + + + include_once "PEAR.php"; + $db->debug =true; + if ($i != 50) { + print "

PEAR DB emulation error 1.1 EOF ($i)

"; + $pear = false; + } + + $rs = $db->limitQuery('select * from adoxyz order by id',$i=3,$top=3); + $i2 = $i; + if ($rs && !$rs->EOF) { + + while (!is_object($rs->fetchInto($arr))) { + $i2++; + + // print_r($arr); + // print "$i ";print_r($arr); + if ($arr[0] != $i2) { + print "

PEAR DB emulation error 2.

"; + $pear = false; + break; + } + } + $rs->Close(); + } + if ($i2 != $i+$top) { + print "

PEAR DB emulation error 2.1 EOF (correct=$i+$top, actual=$i2)

"; + $pear = false; + } + + if ($pear) print "

PEAR DB emulation passed.

"; + + + global $TESTERRS; + $db->debug = false; + $TESTERRS = 0; + $db->raiseErrorFn = 'adodb_test_err'; + $db->Execute('select * from nowhere'); + $rs = $db->Execute('select * from adoxyz'); + $rs->Move(100); + $rs->_queryID = false; + $rs->MoveNext(); + $rs = false; + $conn = NewADOConnection($db->databaseType); + $conn->raiseErrorFn = 'adodb_test_err'; + @$conn->Connect('abc'); + if ($TESTERRS == 2) print "raiseErrorFn tests passed
"; + else print "raiseErrorFn tests failed ($TESTERRS)
"; +?> +

+
 
+

+Close(); + if ($rs2) $rs2->Close(); + if ($rs) $rs->Close(); + $db->Close(); +} + +function adodb_test_err($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false) +{ +global $TESTERRS; + + $TESTERRS += 1; + print "** $dbms ($fn): errno=$errno   errmsg=$errmsg ($p1,$p2)
"; + +} +include('./testdatabases.inc.php'); + +?> +

ADODB Database Library (c) 2000-2002 John Lim. All rights reserved. Released under BSD and LGPL.

+ + diff --git a/lib/adodb/tests/test2.php b/lib/adodb/tests/test2.php new file mode 100644 index 00000000000..f620af3ab8d --- /dev/null +++ b/lib/adodb/tests/test2.php @@ -0,0 +1,54 @@ + + + + + Untitled + + + +PConnect('flipper','','',"test")) + die("Cannot connect to flipper"); +if (!$c2->PConnect('mangrove','root','',"northwind")) + die("Cannot connect to mangrove"); + +print "

Flipper

"; +$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 "

Mangrove

"; +$t = $c2->MetaTables(); +print_r($t); +rs2html($c2->Execute("select * from ".$t[sizeof($t)-1] )); + +print "

Flipper

"; +$t = $c1->MetaTables(); +print_r($t); +rs2html($c1->Execute("select * from ".$t[sizeof($t)-1])); + +?> + + + + diff --git a/lib/adodb/tests/test3.php b/lib/adodb/tests/test3.php new file mode 100644 index 00000000000..9bfafc7dc7f --- /dev/null +++ b/lib/adodb/tests/test3.php @@ -0,0 +1,32 @@ + +PConnect("susetikus","tester","test","test")) + die("Cannot connect to database"); + +# select * from last table in DB +$rs = $c1->Execute("select * from adoxyz order by 1"); + +$i = 0; +$max = $rs->RecordCount(); +if ($max == -1) "RecordCount returns -1
"; +while (!$rs->EOF and $i < $max) { + $rs->Move($i); + print_r( $rs->fields); + print '
'; + $i++; +} +?> +
\ No newline at end of file diff --git a/lib/adodb/tests/test4.php b/lib/adodb/tests/test4.php new file mode 100644 index 00000000000..d20676bf693 --- /dev/null +++ b/lib/adodb/tests/test4.php @@ -0,0 +1,78 @@ +debug=1; +$conn->PConnect("localhost", "root", "", "test"); // connect to MySQL, testdb +$conn->Execute("delete from adoxyz where lastname like 'Smith%'"); + +$rs = $conn->Execute($sql); // Execute the query and get the empty recordset +$record = array(); // Initialize an array to hold the record data to insert + +// Set the values for the fields in the record +$record["firstname"] = "Bob"; +$record["lastname"] = "Smith\$@//"; +$record["created"] = time(); + +// Pass the empty recordset and the array containing the data to insert +// into the GetInsertSQL function. The function will process the data and return +// a fully formatted insert sql statement. +$insertSQL = $conn->GetInsertSQL($rs, $record); + +$conn->Execute($insertSQL); // Insert the record into the database + +//========================== +// This code tests an update + +$sql = "SELECT * FROM ADOXYZ WHERE lastname=".$conn->qstr($record['lastname']); +// Select a record to update + +$rs = $conn->Execute($sql); // Execute the query and get the existing record to update +if (!$rs) print "

No record found!

"; +$record = array(); // Initialize an array to hold the record data to update + +// Set the values for the fields in the record +$record["firstname"] = "Caroline".rand(); +$record["lastname"] = "Smithy"; // Update Caroline's lastname from Miranda to Smith +$record["created"] = '2002-12-'.(rand()%30+1); + +// Pass the single record recordset and the array containing the data to update +// into the GetUpdateSQL function. The function will process the data and return +// a fully formatted update sql statement. +// If the data has not changed, no recordset is returned +$updateSQL = $conn->GetUpdateSQL($rs, $record); + +$conn->Execute($updateSQL); // Update the record in the database +print "

Rows Affected=".$conn->Affected_Rows()."

"; + +rs2html($conn->Execute("select * from adoxyz where lastname like 'Smith%'")); +} + + +testsql(); +?> \ No newline at end of file diff --git a/lib/adodb/tests/test5.php b/lib/adodb/tests/test5.php new file mode 100644 index 00000000000..a392bb7730c --- /dev/null +++ b/lib/adodb/tests/test5.php @@ -0,0 +1,45 @@ +debug=1; + $conn->PConnect("localhost","root","","xphplens"); + print $conn->databaseType.':'.$conn->GenID().'
'; +} + +if (0) { + $conn = &ADONewConnection("oci8"); // create a connection + $conn->debug=1; + $conn->PConnect("falcon", "scott", "tiger", "juris8.ecosystem.natsoft.com.my"); // connect to MySQL, testdb + print $conn->databaseType.':'.$conn->GenID(); +} + +if (0) { + $conn = &ADONewConnection("ibase"); // create a connection + $conn->debug=1; + $conn->Connect("localhost:c:\\Interbase\\Examples\\Database\\employee.gdb", "sysdba", "masterkey", ""); // connect to MySQL, testdb + print $conn->databaseType.':'.$conn->GenID().'
'; +} + +if (0) { + $conn = &ADONewConnection('postgres'); + $conn->debug=1; + @$conn->PConnect("susetikus","tester","test","test"); + print $conn->databaseType.':'.$conn->GenID().'
'; +} +?> diff --git a/lib/adodb/tests/testcache.php b/lib/adodb/tests/testcache.php new file mode 100644 index 00000000000..e55735a05cc --- /dev/null +++ b/lib/adodb/tests/testcache.php @@ -0,0 +1,29 @@ + + +PConnect('nwind'); +} else { + $db = ADONewConnection('mysql'); + $db->PConnect('mangrove','root','','xphplens'); +} +if (isset($cache)) $rs = $db->CacheExecute(120,'select * from products'); +else $rs = $db->Execute('select * from products'); + +$arr = $rs->GetArray(); +print sizeof($arr); +?> \ No newline at end of file diff --git a/lib/adodb/tests/testdatabases.inc.php b/lib/adodb/tests/testdatabases.inc.php new file mode 100644 index 00000000000..a64d6b2a857 --- /dev/null +++ b/lib/adodb/tests/testdatabases.inc.php @@ -0,0 +1,189 @@ +Connecting $db->databaseType..."; + if (@$db->PConnect("susetikus","tester","test","test")) { + testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname varchar,created date)"); + }else + print "ERROR: PostgreSQL requires a database called test on server susetikus, user tester, password test.
".$db->ErrorMsg(); +} +if (!empty($testibase)) { + + $db = &ADONewConnection('ibase'); + print "

Connecting $db->databaseType...

"; + if (@$db->PConnect("localhost:e:\\interbase\\examples\\database\\employee.gdb", "sysdba", "masterkey", "")) + testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname char(24),created date)"); + else print "ERROR: Interbase test requires a database called employee.gdb".'
'.$db->ErrorMsg(); + +} + +// REQUIRES ODBC DSN CALLED nwind +if (!empty($testaccess)) { + + $db = &ADONewConnection('access'); + print "

Connecting $db->databaseType...

"; + + if (@$db->PConnect("nwind", "", "", "")) + testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)"); + else print "ERROR: Access test requires a Windows ODBC DSN=nwind, Access driver"; + +} + +if (!empty($testaccess) && !empty($testado)) { // ADO ACCESS + + $db = &ADONewConnection("ado_access"); + print "

Connecting $db->databaseType...

"; + + $access = 'd:\inetpub\wwwroot\php\NWIND.MDB'; + $myDSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;' + . 'DATA SOURCE=' . $access . ';'; + //. 'USER ID=;PASSWORD=;'; + + if (@$db->PConnect($myDSN, "", "", "")) { + print "ADO version=".$db->_connectionID->version."
"; + testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)"); + } else print "ERROR: Access test requires a Access database $access".'
'.$db->ErrorMsg(); + +} + +if (!empty($testvfp)) { // ODBC + + + $db = &ADONewConnection('vfp'); + print "

Connecting $db->databaseType...

"; + if (@$db->PConnect("logos2", "", "", "")) + testdb($db,"create table d:\\inetpub\\wwwroot\\logos2\\data\\ADOXYZ (id int, firstname char(24), lastname char(24),created date)"); + else print "ERROR: Visual FoxPro test requires a Windows ODBC DSN=logos2, VFP driver"; + +} + + +// REQUIRES MySQL server at localhost with database 'test' +if (!empty($testmysql)) { // MYSQL + + $db = &ADONewConnection('maxsql'); + print "

Connecting $db->databaseType...

"; + if ($HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost'; + else $server = "mangrove"; + if ($db->PConnect($server, "root", "", "test")) + testdb($db, + "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) type=innodb"); + else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'
'.$db->ErrorMsg(); + + $db = &ADONewConnection('proxy'); + print "

Connecting $db->databaseType...

"; + if ($HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost'; + + if ($db->PConnect('http://localhost/php/phplens/adodb/server.php')) + testdb($db, + "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) type=innodb"); + else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'
'.$db->ErrorMsg(); + +} + +ADOLoadCode('oci805'); +ADOLoadCode("oci8po"); +if (!empty($testoracle)) { + + $db = ADONewConnection(); + print "

Connecting $db->databaseType...

"; + if ($db->Connect('', "scott", "tiger",'natsoft.ecosystem.natsoft.com.my')) + //if ($db->PConnect("", "scott", "tiger", "juris.ecosystem.natsoft.com.my")) + testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); + else print "ERROR: Oracle test requires an Oracle server setup with scott/tiger".'
'.$db->ErrorMsg(); + +} +ADOLoadCode("oracle"); // no longer supported +if (false && !empty($testoracle)) { + + $db = ADONewConnection(); + print "

Connecting $db->databaseType...

"; + if ($db->PConnect("", "scott", "tiger", "natsoft.domain")) + testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); + else print "ERROR: Oracle test requires an Oracle server setup with scott/tiger".'
'.$db->ErrorMsg(); + +} + + +ADOLoadCode("odbc_mssql"); +if (!empty($testmssql) and false) { // MS SQL Server via ODBC + + $db = ADONewConnection(); + + print "

Connecting $db->databaseType...

"; + if (@$db->PConnect("sqlserver", "sa", "natsoft", "")) + testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)"); + else print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN='sqlserver', userid='sa', password='natsoft'"; + +} + +ADOLoadCode("ado_mssql"); + +if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC -- DSN-less + + $db = &ADONewConnection("ado_mssql"); + print "

Connecting DSN-less $db->databaseType...

"; + + $myDSN="PROVIDER=MSDASQL;DRIVER={SQL Server};" + . "SERVER=(local);DATABASE=NorthWind;UID=sa;PWD=natsoft;" ; + + + if (@$db->PConnect($myDSN, "", "", "")) + testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)"); + else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='mangrove', userid='sa', password='natsoft', database='ai'"; + +} + + +ADOLoadCode("mssql"); +if (!empty($testmssql)) { // MS SQL Server -- the extension is buggy -- probably better to use ODBC + $db = ADONewConnection(); + print "

Connecting $db->databaseType...

"; + + $db->Connect('(local)\NetSDK','','','northwind'); + + if (true or @$db->PConnect("mangrove", "sa", "natsoft", "ai")) { + AutoDetect_MSSQL_Date_Order($db); + testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)"); + } else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='192.168.0.1', userid='sa', password='natsoft', database='ai'".'
'.$db->ErrorMsg(); + +} + +if (!empty($testmssql) && !empty($testado)) { // ADO ACCESS MSSQL with OLEDB provider + + $db = &ADONewConnection("ado_mssql"); + print "

Connecting DSN-less OLEDB Provider $db->databaseType...

"; + + $myDSN="SERVER=mangrove;DATABASE=ai;"; + //$myDSN='SERVER=(local)\NetSDK;DATABASE=northwind;'; + if ($db->PConnect($myDSN, "sa", "natsoft", 'SQLOLEDB')) + testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)"); + else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='mangrove', userid='sa', password='', database='ai'"; + +} + + +print "

Tests Completed

"; + +?> diff --git a/lib/adodb/tests/testgenid.php b/lib/adodb/tests/testgenid.php new file mode 100644 index 00000000000..51e3b0afbaa --- /dev/null +++ b/lib/adodb/tests/testgenid.php @@ -0,0 +1,34 @@ +Execute("drop table $table"); + //$db->debug=true; + + $ctr = 5000; + $lastnum = 0; + + while (--$ctr >= 0) { + $num = $db->GenID($table); + if ($num === false) { + print "GenID returned false"; + break; + } + if ($lastnum + 1 == $num) print " $num "; + else { + print " $num "; + flush(); + } + $lastnum = $num; + } +} +?> \ No newline at end of file diff --git a/lib/adodb/tests/testoci8.php b/lib/adodb/tests/testoci8.php new file mode 100644 index 00000000000..735e93e2704 --- /dev/null +++ b/lib/adodb/tests/testoci8.php @@ -0,0 +1,70 @@ + + +PConnect('','scott','tiger','natsoftmts'); + $db->debug = true; + + if (!empty($testblob)) { + $varHoldingBlob = 'ABC DEF GEF John TEST'; + $num = time()%10240; + // create table atable (id integer, ablob blob); + $db->Execute('insert into ATABLE (id,ablob) values('.$num.',empty_blob())'); + $db->UpdateBlob('ATABLE', 'ablob', $varHoldingBlob, 'id='.$num, 'BLOB'); + + $rs = &$db->Execute('select * from atable'); + + if (!$rs) die("Empty RS"); + if ($rs->EOF) die("EOF RS"); + rs2html($rs); + } + $stmt = $db->Prepare('select * from adoxyz where id=?'); + for ($i = 1; $i <= 10; $i++) { + $rs = &$db->Execute( + $stmt, + array($i)); + + if (!$rs) die("Empty RS"); + if ($rs->EOF) die("EOF RS"); + rs2html($rs); + } +} +if (1) { + $db = ADONewConnection('oci8'); + $db->PConnect('','scott','tiger'); + $db->debug = true; + $db->Execute("delete from emp where ename='John'"); + print $db->Affected_Rows().'
'; + $stmt = &$db->Prepare('insert into emp (empno, ename) values (:empno, :ename)'); + $rs = $db->Execute($stmt,array('empno'=>4321,'ename'=>'John')); + // prepare not quite ready for prime time + //$rs = $db->Execute($stmt,array('empno'=>3775,'ename'=>'John')); + if (!$rs) die("Empty RS"); +} + +if (0) { + $db = ADONewConnection('odbc_oracle'); + if (!$db->PConnect('local_oracle','scott','tiger')) die('fail connect'); + $db->debug = true; + $rs = &$db->Execute( + 'select * from adoxyz where firstname=? and trim(lastname)=?', + array('first'=>'Caroline','last'=>'Miranda')); + if (!$rs) die("Empty RS"); + if ($rs->EOF) die("EOF RS"); + rs2html($rs); +} +?> \ No newline at end of file diff --git a/lib/adodb/tests/testpaging.php b/lib/adodb/tests/testpaging.php new file mode 100644 index 00000000000..e3ac3c68e61 --- /dev/null +++ b/lib/adodb/tests/testpaging.php @@ -0,0 +1,54 @@ +debug = true; +//$db->Connect('localhost:4321','scott','tiger','natsoft.domain'); +$db->Connect('localhost','root','','xphplens'); + +$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()) { +?> +First page   +Previous page   +AtLastPage()) { +?> +Next Page + diff --git a/lib/adodb/tests/testpear.php b/lib/adodb/tests/testpear.php new file mode 100644 index 00000000000..c0e69b21672 --- /dev/null +++ b/lib/adodb/tests/testpear.php @@ -0,0 +1,34 @@ +setFetchMode(ADODB_FETCH_ASSOC); +$rs = $db->Query('select firstname,lastname from adoxyz'); +$cnt = 0; +while ($arr = $rs->FetchRow()) { + print_r($arr); + print "
"; + $cnt += 1; +} + +if ($cnt != 50) print "Error in \$cnt = $cnt"; +?> \ No newline at end of file diff --git a/lib/adodb/tests/testsessions.php b/lib/adodb/tests/testsessions.php new file mode 100644 index 00000000000..e2727608cce --- /dev/null +++ b/lib/adodb/tests/testsessions.php @@ -0,0 +1,24 @@ +\$HTTP_SESSION_VARS['AVAR']={$HTTP_SESSION_VARS['AVAR']}

"; + +?> \ No newline at end of file