From 7f55604b4a97de521f0829a57bb634c903b5b05c Mon Sep 17 00:00:00 2001
From: Ignacio Vazquez-Abrams ";
+- return;
+- }
+- $arr = $rs->GetArray();
+- //$db->debug = true;
+- global $ADODB_COUNTRECS;
+- $ADODB_COUNTRECS = false;
+- $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
";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 "
"; +- echo $e; +- echo ""; +-} +- +-?> +\ No newline at end of file +diff -urN moodle/lib/adodb/tests/test2.php moodle.adodb/lib/adodb/tests/test2.php +--- moodle/lib/adodb/tests/test2.php 2005-05-24 02:07:02.000000000 -0400 ++++ moodle.adodb/lib/adodb/tests/test2.php 1969-12-31 19:00:00.000000000 -0500 +@@ -1,26 +0,0 @@ +-debug=1; +- $access = 'd:\inetpub\wwwroot\php\NWIND.MDB'; +- $myDSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;' +- . 'DATA SOURCE=' . $access . ';'; +- +- echo "
PHP ",PHP_VERSION,"
"; +- +- $db->Connect($myDSN) || die('fail'); +- +- print_r($db->ServerInfo()); +- +- try { +- $rs = $db->Execute("select $db->sysTimeStamp,* from adoxyz where id>02xx"); +- print_r($rs->fields); +- } catch(exception $e) { +- print_r($e); +- echo "Date m/d/Y =",$db->UserDate($rs->fields[4],'m/d/Y'); +- } +-?> +\ No newline at end of file +diff -urN moodle/lib/adodb/tests/test3.php moodle.adodb/lib/adodb/tests/test3.php +--- moodle/lib/adodb/tests/test3.php 2005-11-10 21:05:25.000000000 -0500 ++++ moodle.adodb/lib/adodb/tests/test3.php 1969-12-31 19:00:00.000000000 -0500 +@@ -1,44 +0,0 @@ +-Connect('','scott','natsoft'); +-$db->debug=1; +- +-$cnt = $db->GetOne("select count(*) from adoxyz"); +-$rs = $db->Execute("select * from adoxyz order by id"); +- +-$i = 0; +-foreach($rs as $k => $v) { +- $i += 1; +- echo $k; adodb_pr($v); +- flush(); +-} +- +-if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n"); +- +- +- +-$rs = $db->Execute("select bad from badder"); +- +-} catch (exception $e) { +- adodb_pr($e); +- $e = adodb_backtrace($e->trace); +-} +- +-?> +\ No newline at end of file +diff -urN moodle/lib/adodb/tests/test4.php moodle.adodb/lib/adodb/tests/test4.php +--- moodle/lib/adodb/tests/test4.php 2005-05-24 02:07:02.000000000 -0400 ++++ moodle.adodb/lib/adodb/tests/test4.php 1969-12-31 19:00:00.000000000 -0500 +@@ -1,134 +0,0 @@ +-PConnect("", "sa", "natsoft", "northwind"); // connect to MySQL, testdb +- +-$conn = &ADONewConnection("mysql"); // create a connection +-$conn->PConnect("localhost", "root", "", "test"); // connect to MySQL, testdb +- +-//$conn =& ADONewConnection('oci8'); +-//$conn->Connect('','scott','natsoft'); +-//$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; +- +-$conn->debug=1; +-$conn->Execute("delete from adoxyz where lastname like 'Smi%'"); +- +-$rs = $conn->Execute($sql); // Execute the query and get the empty recordset +-$record = array(); // Initialize an array to hold the record data to insert +- +-if (strpos($conn->databaseType,'mssql')!==false) $record['id'] = 751; +-$record["firstname"] = 'Jann'; +-$record["lastname"] = "Smitts"; +-$record["created"] = time(); +- +-$insertSQL = $conn->GetInsertSQL($rs, $record); +-$conn->Execute($insertSQL); // Insert the record into the database +- +-if (strpos($conn->databaseType,'mssql')!==false) $record['id'] = 752; +-// Set the values for the fields in the record +-$record["firstname"] = 'null'; +-$record["lastname"] = "Smith\$@//"; +-$record["created"] = time(); +- +-if (isset($_GET['f'])) $ADODB_FORCE_TYPE = $_GET['f']; +- +-//$record["id"] = -1; +- +-// Pass the empty recordset and the array containing the data to insert +-// into the GetInsertSQL function. The function will process the data and return +-// a fully formatted insert sql statement. +-$insertSQL = $conn->GetInsertSQL($rs, $record); +-$conn->Execute($insertSQL); // Insert the record into the database +- +- +- +-$insertSQL2 = $conn->GetInsertSQL($table='ADOXYZ', $record); +-if ($insertSQL != $insertSQL2) echo "
Walt's new stuff failed: $insertSQL2
"; +-//========================== +-// This code tests an update +- +-$sql = " +-SELECT * +-FROM ADOXYZ WHERE lastname=".$conn->Param('var'). " ORDER BY 1"; +-// Select a record to update +- +-$varr = array('var'=>$record['lastname'].''); +-$rs = $conn->Execute($sql,$varr); // Execute the query and get the existing record to update +-if (!$rs || $rs->EOF) print "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"] = ""; // Update Caroline's lastname from Miranda to Smith +-$record["creAted"] = '2002-12-'.(rand()%30+1); +-$record['num'] = ''; +-// Pass the single record recordset and the array containing the data to update +-// into the GetUpdateSQL function. The function will process the data and return +-// a fully formatted update sql statement. +-// If the data has not changed, no recordset is returned +- +-$updateSQL = $conn->GetUpdateSQL($rs, $record); +-$conn->Execute($updateSQL,$varr); // Update the record in the database +-if ($conn->Affected_Rows() != 1)print "Error1 : Rows Affected=".$conn->Affected_Rows().", should be 1
"; +- +-$record["firstName"] = "Caroline".rand(); +-$record["lasTname"] = "Smithy Jones"; // Update Caroline's lastname from Miranda to Smith +-$record["creAted"] = '2002-12-'.(rand()%30+1); +-$record['num'] = 331; +-$updateSQL = $conn->GetUpdateSQL($rs, $record); +-$conn->Execute($updateSQL,$varr); // Update the record in the database +-if ($conn->Affected_Rows() != 1)print "Error 2: Rows Affected=".$conn->Affected_Rows().", should be 1
"; +- +-$rs = $conn->Execute("select * from ADOXYZ where lastname like 'Sm%'"); +-//adodb_pr($rs); +-rs2html($rs); +- +-$record["firstName"] = "Carol-new-".rand(); +-$record["lasTname"] = "Smithy"; // Update Caroline's lastname from Miranda to Smith +-$record["creAted"] = '2002-12-'.(rand()%30+1); +-$record['num'] = 331; +- +-$conn->AutoExecute('ADOXYZ',$record,'UPDATE', "lastname like 'Sm%'"); +-$rs = $conn->Execute("select * from ADOXYZ where lastname like 'Sm%'"); +-//adodb_pr($rs); +-rs2html($rs); +-} +- +- +-testsql(); +-?> +\ No newline at end of file +diff -urN moodle/lib/adodb/tests/test5.php moodle.adodb/lib/adodb/tests/test5.php +--- moodle/lib/adodb/tests/test5.php 2005-11-10 21:05:25.000000000 -0500 ++++ moodle.adodb/lib/adodb/tests/test5.php 1969-12-31 19:00:00.000000000 -0500 +@@ -1,47 +0,0 @@ +-debug=1; +- $conn->PConnect("localhost","root","","xphplens"); +- print $conn->databaseType.':'.$conn->GenID().'+- |
"; +- $db = NewADOConnection($dbType); +- $dict = NewDataDictionary($db); +- +- if (!$dict) continue; +- $dict->debug = 1; +- +- $opts = array('REPLACE','mysql' => 'TYPE=INNODB', 'oci8' => 'TABLESPACE USERS'); +- +-/* $flds = array( +- array('id', 'I', +- 'AUTO','KEY'), +- +- array('name' => 'firstname', 'type' => 'varchar','size' => 30, +- 'DEFAULT'=>'Joan'), +- +- array('lastname','varchar',28, +- 'DEFAULT'=>'Chen','key'), +- +- array('averylonglongfieldname','X',1024, +- 'NOTNULL','default' => 'test'), +- +- array('price','N','7.2', +- 'NOTNULL','default' => '0.00'), +- +- array('MYDATE', 'D', +- 'DEFDATE'), +- array('TS','T', +- 'DEFTIMESTAMP') +- );*/ +- +- $flds = " +-ID I AUTO KEY, +-FIRSTNAME VARCHAR(30) DEFAULT 'Joan', +-LASTNAME VARCHAR(28) DEFAULT 'Chen' key, +-averylonglongfieldname X(1024) DEFAULT 'test', +-price N(7.2) DEFAULT '0.00', +-MYDATE D DEFDATE, +-BIGFELLOW X NOTNULL, +-TS T DEFTIMESTAMP"; +- +- +- $sqla = $dict->CreateDatabase('KUTU',array('postgres'=>"LOCATION='/u01/postdata'")); +- $dict->SetSchema('KUTU'); +- +- $sqli = ($dict->CreateTableSQL('testtable',$flds, $opts)); +- $sqla = array_merge($sqla,$sqli); +- +- $sqli = $dict->CreateIndexSQL('idx','testtable','firstname,lastname',array('BITMAP','FULLTEXT','CLUSTERED','HASH')); +- $sqla = array_merge($sqla,$sqli); +- $sqli = $dict->CreateIndexSQL('idx2','testtable','price,lastname');//,array('BITMAP','FULLTEXT','CLUSTERED')); +- $sqla = array_merge($sqla,$sqli); +- +- $addflds = array(array('height', 'F'),array('weight','F')); +- $sqli = $dict->AddColumnSQL('testtable',$addflds); +- $sqla = array_merge($sqla,$sqli); +- $addflds = array(array('height', 'F','NOTNULL'),array('weight','F','NOTNULL')); +- $sqli = $dict->AlterColumnSQL('testtable',$addflds); +- $sqla = array_merge($sqla,$sqli); +- +- +- printsqla($dbType,$sqla); +- +- if (file_exists('d:\inetpub\wwwroot\php\phplens\adodb\adodb.inc.php')) +- if ($dbType == 'mysqlt') { +- $db->Connect('localhost', "root", "", "test"); +- $dict->SetSchema(''); +- $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds); +- if ($sqla2) printsqla($dbType,$sqla2); +- } +- if ($dbType == 'postgres') { +- if (@$db->Connect('localhost', "tester", "test", "test")); +- $dict->SetSchema(''); +- $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds); +- if ($sqla2) printsqla($dbType,$sqla2); +- } +- +- if ($dbType == 'odbc_mssql') { +- $dsn = $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=localhost;Database=northwind;"; +- if (@$db->Connect($dsn, "sa", "natsoft", "test")); +- $dict->SetSchema(''); +- $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds); +- if ($sqla2) printsqla($dbType,$sqla2); +- } +- +- +- +- adodb_pr($dict->databaseType); +- printsqla($dbType, $dict->DropColumnSQL('table',array('my col','`col2_with_Quotes`','A_col3','col3(10)'))); +- printsqla($dbType, $dict->ChangeTableSQL('adoxyz','LASTNAME varchar(32)')); +- +-} +- +-function printsqla($dbType,$sqla) +-{ +- print "
"; +- //print_r($dict->MetaTables()); +- foreach($sqla as $s) { +- $s = htmlspecialchars($s); +- print "$s;\n"; +- if ($dbType == 'oci8') print "/\n"; +- } +- print "
"; +-foreach($ff as $xml) echo htmlspecialchars($xml); +-echo ""; +-include_once('test-xmlschema.php'); +-?> +\ No newline at end of file +diff -urN moodle/lib/adodb/tests/testgenid.php moodle.adodb/lib/adodb/tests/testgenid.php +--- moodle/lib/adodb/tests/testgenid.php 2004-07-12 23:13:35.000000000 -0400 ++++ moodle.adodb/lib/adodb/tests/testgenid.php 1969-12-31 19:00:00.000000000 -0500 +@@ -1,36 +0,0 @@ +-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 -urN moodle/lib/adodb/tests/testmssql.php moodle.adodb/lib/adodb/tests/testmssql.php +--- moodle/lib/adodb/tests/testmssql.php 2005-11-10 21:05:25.000000000 -0500 ++++ moodle.adodb/lib/adodb/tests/testmssql.php 1969-12-31 19:00:00.000000000 -0500 +@@ -1,76 +0,0 @@ +-Connect('127.0.0.1','adodb','natsoft','northwind') or die('Fail'); +- +-$conn->debug =1; +-$query = 'select * from products'; +-$conn->SetFetchMode(ADODB_FETCH_ASSOC); +-$rs = $conn->Execute($query); +-echo "
"; +-while( !$rs->EOF ) { +- $output[] = $rs->fields; +- var_dump($rs->fields); +- $rs->MoveNext(); +- print "+-Close(); +- if ($rs2) $rs2->Close(); +- if ($rs) $rs->Close(); +- $db->Close(); +- +- if ($db->transCnt != 0) Err("Error in transCnt=$db->transCnt (should be 0)"); +- +- +- printf(""; +-} +-die(); +- +- +-$p = $conn->Prepare('insert into products (productname,unitprice,dcreated) values (?,?,?)'); +-echo "
"; +-print_r($p); +- +-$conn->debug=1; +-$conn->Execute($p,array('John'.rand(),33.3,$conn->DBDate(time()))); +- +-$p = $conn->Prepare('select * from products where productname like ?'); +-$arr = $conn->getarray($p,array('V%')); +-print_r($arr); +-die(); +- +-//$conn = &ADONewConnection("mssql"); +-//$conn->Connect('mangrove','sa','natsoft','ai'); +- +-//$conn->Connect('mangrove','sa','natsoft','ai'); +-$conn->debug=1; +-$conn->Execute('delete from blobtest'); +- +-$conn->Execute('insert into blobtest (id) values(1)'); +-$conn->UpdateBlobFile('blobtest','b1','../cute_icons_for_site/adodb.gif','id=1'); +-$rs = $conn->Execute('select b1 from blobtest where id=1'); +- +-$output = "c:\\temp\\test_out-".date('H-i-s').".gif"; +-print "Saving file $output, size=".strlen($rs->fields[0]).""; +-$fd = fopen($output, "wb"); +-fwrite($fd, $rs->fields[0]); +-fclose($fd); +- +-print " View Image"; +-//$rs = $conn->Execute('SELECT id,SUBSTRING(b1, 1, 10) FROM blobtest'); +-//rs2html($rs); +-?> +\ No newline at end of file +diff -urN moodle/lib/adodb/tests/testoci8cursor.php moodle.adodb/lib/adodb/tests/testoci8cursor.php +--- moodle/lib/adodb/tests/testoci8cursor.php 2005-11-10 21:05:25.000000000 -0500 ++++ moodle.adodb/lib/adodb/tests/testoci8cursor.php 1969-12-31 19:00:00.000000000 -0500 +@@ -1,111 +0,0 @@ +-PConnect('','scott','natsoft'); +- $db->debug = 99; +- +- +-/* +-*/ +- +- define('MYNUM',5); +- +- +- $rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:RS,'A%'); END;"); +- +- if ($rs && !$rs->EOF) { +- print "Test 1 RowCount: ".$rs->RecordCount()."
"; +- } else { +- print "Error in using Cursor Variables 1
"; +- } +- +- print "
Testing Stored Procedures for oci8
"; +- +- $stid = $db->PrepareSP('BEGIN adodb.myproc('.MYNUM.', :myov); END;'); +- $db->OutParameter($stid, $myov, 'myov'); +- $db->Execute($stid); +- if ($myov != MYNUM) print "Error with myproc
"; +- +- +- $stmt = $db->PrepareSP("BEGIN adodb.data_out(:a1, :a2); END;",true); +- $a1 = 'Malaysia'; +- //$a2 = ''; # a2 doesn't even need to be defined! +- $db->InParameter($stmt,$a1,'a1'); +- $db->OutParameter($stmt,$a2,'a2'); +- $rs = $db->Execute($stmt); +- if ($rs) { +- if ($a2 !== 'Cinta Hati Malaysia') print "Stored Procedure Error: a2 = $a2"; +- else echo "OK: a2=$a2
"; +- } else { +- print "Error in using Stored Procedure IN/Out Variables
"; +- } +- +- +- $tname = 'A%'; +- +- $stmt = $db->PrepareSP('select * from tab where tname like :tablename'); +- $db->Parameter($stmt,$tname,'tablename'); +- $rs = $db->Execute($stmt); +- rs2html($rs); +- +- +-?> +\ No newline at end of file +diff -urN moodle/lib/adodb/tests/testoci8.php moodle.adodb/lib/adodb/tests/testoci8.php +--- moodle/lib/adodb/tests/testoci8.php 2005-11-10 21:05:25.000000000 -0500 ++++ moodle.adodb/lib/adodb/tests/testoci8.php 1969-12-31 19:00:00.000000000 -0500 +@@ -1,83 +0,0 @@ +- +-
+-PConnect('','scott','natsoft'); +- 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','natsoft'); +- $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"); +- +- $db->setfetchmode(ADODB_FETCH_NUM); +- +- $vv = 'A%'; +- $stmt = $db->PrepareSP("BEGIN adodb.open_tab2(:rs,:tt); END;",true); +- $db->OutParameter($stmt, $cur, 'rs', -1, OCI_B_CURSOR); +- $db->OutParameter($stmt, $vv, 'tt'); +- $rs = $db->Execute($stmt); +- while (!$rs->EOF) { +- adodb_pr($rs->fields); +- $rs->MoveNext(); +- } +- echo " val = $vv"; +- +-} +- +-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 -urN moodle/lib/adodb/tests/testpaging.php moodle.adodb/lib/adodb/tests/testpaging.php +--- moodle/lib/adodb/tests/testpaging.php 2005-11-10 21:05:25.000000000 -0500 ++++ moodle.adodb/lib/adodb/tests/testpaging.php 1969-12-31 19:00:00.000000000 -0500 +@@ -1,86 +0,0 @@ +-PConnect('localhost','tester','test','test'); +-} +- +-if ($driver == 'access') { +- $db = NewADOConnection('access'); +- $db->PConnect("nwind", "", "", ""); +-} +- +-if ($driver == 'ibase') { +- $db = NewADOConnection('ibase'); +- $db->PConnect("localhost:e:\\firebird\\examples\\employee.gdb", "sysdba", "masterkey", ""); +- $sql = 'select distinct firstname, lastname from adoxyz order by firstname'; +- +-} +-if ($driver == 'mssql') { +- $db = NewADOConnection('mssql'); +- $db->Connect('JAGUAR\vsdotnet','adodb','natsoft','northwind'); +-} +-if ($driver == 'oci8') { +- $db = NewADOConnection('oci8'); +- $db->Connect('','scott','natsoft'); +- +-$sql = "select * from (select ID, firstname as \"First Name\", lastname as \"Last Name\" from adoxyz +- order by (1))"; +-} +- +-if ($driver == 'access') { +- $db = NewADOConnection('access'); +- $db->Connect('nwind'); +-} +- +-if (empty($driver) or $driver == 'mysql') { +- $db = NewADOConnection('mysql'); +- $db->Connect('localhost','root','','test'); +-} +- +-//$db->pageExecuteCountRows = false; +- +-$db->debug = true; +- +-if (0) { +-$rs = &$db->Execute($sql); +-include_once('../toexport.inc.php'); +-print ""; +-print rs2csv($rs); # return a string +- +-print '"; +-} +- +-$pager = new ADODB_Pager($db,$sql); +-$pager->showPageLinks = true; +-$pager->linksPerPage = 10; +-$pager->cache = 60; +-$pager->Render($rows=7); +-?> +\ No newline at end of file +diff -urN moodle/lib/adodb/tests/testpear.php moodle.adodb/lib/adodb/tests/testpear.php +--- moodle/lib/adodb/tests/testpear.php 2005-11-10 21:05:25.000000000 -0500 ++++ moodle.adodb/lib/adodb/tests/testpear.php 1969-12-31 19:00:00.000000000 -0500 +@@ -1,34 +0,0 @@ +-setFetchMode(ADODB_FETCH_ASSOC); +-$rs = $db->Query('select firstname,lastname from adoxyz'); +-$cnt = 0; +-while ($arr = $rs->FetchRow()) { +- print_r($arr); +- print "
'; +-$rs->MoveFirst(); # note, some databases do not support MoveFirst +-print rs2tab($rs); # return a string +- +-print '
'; +-$rs->MoveFirst(); +-rs2tabout($rs); # send to stdout directly +-print "
"; +- $cnt += 1; +-} +- +-if ($cnt != 50) print "Error in \$cnt = $cnt"; +-?> +\ No newline at end of file +diff -urN moodle/lib/adodb/tests/test-perf.php moodle.adodb/lib/adodb/tests/test-perf.php +--- moodle/lib/adodb/tests/test-perf.php 2003-10-22 04:52:42.000000000 -0400 ++++ moodle.adodb/lib/adodb/tests/test-perf.php 1969-12-31 19:00:00.000000000 -0500 +@@ -1,50 +0,0 @@ +- $v) { +- if (strncmp($k,'test',4) == 0) $_SESSION['_db'] = $k; +- } +-} +- +-if (isset($_SESSION['_db'])) { +- $_db = $_SESSION['_db']; +- $_GET[$_db] = 1; +- $$_db = 1; +-} +- +-echo "Performance Monitoring
"; +-include_once('testdatabases.inc.php'); +- +- +-function testdb($db) +-{ +- if (!$db) return; +- echo "";print_r($db->ServerInfo()); echo " user=".$db->user.""; +- +- $perf = NewPerfMonitor($db); +- +- # unit tests +- if (0) { +- //$DB->debug=1; +- echo "Data Cache Size=".$perf->DBParameter('data cache size').''; +- echo $perf->HealthCheck(); +- echo($perf->SuspiciousSQL()); +- echo($perf->ExpensiveSQL()); +- echo($perf->InvalidSQL()); +- echo $perf->Tables(); +- +- echo "
"; +- echo $perf->HealthCheckCLI(); +- $perf->Poll(3); +- die(); +- } +- +- if ($perf) $perf->UI(3); +-} +- +-?> +diff -urN moodle/lib/adodb/tests/test-pgblob.php moodle.adodb/lib/adodb/tests/test-pgblob.php +--- moodle/lib/adodb/tests/test-pgblob.php 2004-03-06 21:33:26.000000000 -0500 ++++ moodle.adodb/lib/adodb/tests/test-pgblob.php 1969-12-31 19:00:00.000000000 -0500 +@@ -1,88 +0,0 @@ +-Param(false); +- $x = (rand() % 10) + 1; +- $db->debug= ($i==1); +- $id = $db->GetOne($sql, +- array('Z%','Z%',$x)); +- if($id != $offset+$x) { +- print "Error at $x"; +- break; +- } +- } +-} +- +-include_once('../adodb.inc.php'); +-$db = NewADOConnection('postgres7'); +-$db->PConnect('localhost','tester','test','test') || die("failed connection"); +- +-$enc = "GIF89a%01%00%01%00%80%FF%00%C0%C0%C0%00%00%00%21%F9%04%01%00%00%00%00%2C%00%00%00%00%01%00%01%00%00%01%012%00%3Bt_clear.gif%0D"; +-$val = rawurldecode($enc); +- +-$MAX = 1000; +- +-adodb_pr($db->ServerInfo()); +- +-echo "
Testing PREPARE/EXECUTE PLAN
"; +- +- +-$db->_bindInputArray = true; // requires postgresql 7.3+ and ability to modify database +-$t = getmicrotime(); +-doloop(); +-echo '',$MAX,' times, with plan=',getmicrotime() - $t,'
'; +- +- +-$db->_bindInputArray = false; +-$t = getmicrotime(); +-doloop(); +-echo '',$MAX,' times, no plan=',getmicrotime() - $t,'
'; +- +- +- +-echo "Testing UPDATEBLOB
"; +-$db->debug=1; +- +-### TEST BEGINS +- +-$db->Execute("insert into photos (id,name) values(9999,'dot.gif')"); +-$db->UpdateBlob('photos','photo',$val,'id=9999'); +-$v = $db->GetOne('select photo from photos where id=9999'); +- +- +-### CLEANUP +- +-$db->Execute("delete from photos where id=9999"); +- +-### VALIDATION +- +-if ($v !== $val) echo "*** ERROR: Inserted value does not match downloaded val"; +-else echo "*** OK: Passed"; +- +-echo ""; +-echo "INSERTED: ", $enc; +-echo "
"; +-echo"RETURNED: ", rawurlencode($v); +-echo ""; +-echo "INSERTED: ", $val; +-echo "
"; +-echo "RETURNED: ", $v; +- +-?> +\ No newline at end of file +diff -urN moodle/lib/adodb/tests/test.php moodle.adodb/lib/adodb/tests/test.php +--- moodle/lib/adodb/tests/test.php 2005-11-10 21:05:25.000000000 -0500 ++++ moodle.adodb/lib/adodb/tests/test.php 1969-12-31 19:00:00.000000000 -0500 +@@ -1,1705 +0,0 @@ +-$msg
"; +- flush(); +-} +- +-function CheckWS($conn) +-{ +-global $ADODB_EXTENSION; +- +- include_once('../session/adodb-session.php'); +- if (defined('CHECKWSFAIL')){ echo " TESTING $conn ";flush();} +- $saved = $ADODB_EXTENSION; +- $db = ADONewConnection($conn); +- $ADODB_EXTENSION = $saved; +- if (headers_sent()) { +- print "White space detected in adodb-$conn.inc.php or include file...
"; +- //die(); +- } +-} +- +-function do_strtolower(&$arr) +-{ +- foreach($arr as $k => $v) { +- if (is_object($v)) $arr[$k] = adodb_pr($v,true); +- else $arr[$k] = strtolower($v); +- } +-} +- +- +-function CountExecs($db, $sql, $inputarray) +-{ +-global $EXECS; $EXECS++; +-} +- +-function CountCachedExecs($db, $secs2cache, $sql, $inputarray) +-{ +-global $CACHED; $CACHED++; +-} +- +-// 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,$ADODB_COUNTRECS; +- +-?>
Total queries=%d; total cached=%d
",$EXECS+$CACHED, $CACHED); +- flush(); +-} +- +-function adodb_test_err($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false) +-{ +-global $TESTERRS,$ERRNO; +- +- $ERRNO = $errno; +- $TESTERRS += 1; +- print "** $dbms ($fn): errno=$errno errmsg=$errmsg ($p1,$p2)"; +-} +-if (sizeof($_GET) == 0) $testmysql = true; +- +- +-foreach($_GET as $k=>$v) { +- //global $$k; +- $$k = $v; +-} +-if (strpos(PHP_VERSION,'5') === 0) { +- //$testaccess=1; +- //$testmssql = 1; +- //$testsqlite=1; +-} +-?> +- +-
+-vers=",ADOConnection::Version(); +- +- +-include_once('../adodb-time.inc.php'); +-if (isset($_GET['time'])) adodb_date_test(); +- +-?> +-
ADODB Database Library (c) 2000-2005 John Lim. All rights reserved. Released under BSD and LGPL, PHP .
+- +- +diff -urN moodle/lib/adodb/tests/test-php5.php moodle.adodb/lib/adodb/tests/test-php5.php +--- moodle/lib/adodb/tests/test-php5.php 2005-11-10 21:05:25.000000000 -0500 ++++ moodle.adodb/lib/adodb/tests/test-php5.php 1969-12-31 19:00:00.000000000 -0500 +@@ -1,78 +0,0 @@ +-PHP ".PHP_VERSION."\n"; +-try { +- +-$dbt = 'mysql'; +- +-try { +-switch($dbt) { +-case 'oci8po': +- $db = NewADOConnection("oci8po"); +- +- $db->Connect('','scott','natsoft'); +- break; +-default: +-case 'mysql': +- $db = NewADOConnection("mysql"); +- $db->Connect('localhost','roots','','northwind'); +- break; +- +-case 'mysqli': +- $db = NewADOConnection("mysqli://root:@localhost/northwind"); +- //$db->Connect('localhost','root','','test'); +- break; +-} +-} catch (exception $e){ +- echo "Connect Failed"; +- adodb_pr($e); +- die(); +-} +- +-$db->debug=1; +- +-$cnt = $db->GetOne("select count(*) from adoxyz where ?\$_SESSION['AVAR']={$_SESSION['AVAR']}
"; +- +- print "Garbage Collection
"; +- adodb_sess_gc(10); +- +- if (rand() % 2 == 0) { +- print "Random session destroy
"; +- session_destroy(); +- } +- } +-?> +\ No newline at end of file +diff -urN moodle/lib/adodb/tests/test-xmlschema.php moodle.adodb/lib/adodb/tests/test-xmlschema.php +--- moodle/lib/adodb/tests/test-xmlschema.php 2005-11-10 21:05:25.000000000 -0500 ++++ moodle.adodb/lib/adodb/tests/test-xmlschema.php 1969-12-31 19:00:00.000000000 -0500 +@@ -1,54 +0,0 @@ +-Connect( 'localhost', 'root', '', 'schematest' ); +- +-// To create a schema object and build the query array. +-$schema = new adoSchema( $db ); +- +-// To upgrade an existing schema object, use the following +-// To upgrade an existing database to the provided schema, +-// uncomment the following line: +-#$schema->upgradeSchema(); +- +-print "SQL to build xmlschema.xml:\n"; +-// Build the SQL array +-$sql = $schema->ParseSchema( "xmlschema.xml" ); +- +-print_r( $sql ); +-print "\n"; +- +-// Execute the SQL on the database +-//$result = $schema->ExecuteSchema( $sql ); +- +-// Finally, clean up after the XML parser +-// (PHP won't do this for you!) +-//$schema->Destroy(); +- +- +- +-print "SQL to build xmlschema-mssql.xml:\n
"; +- +-$db2 = ADONewConnection('mssql'); +-$db2->Connect('','adodb','natsoft','northwind') || die("Fail 2"); +- +-$db2->Execute("drop table simple_table"); +- +-$schema = new adoSchema( $db2 ); +-$sql = $schema->ParseSchema( "xmlschema-mssql.xml" ); +- +-print_r( $sql ); +-print "\n"; +- +-$db2->debug=1; +- +-foreach ($sql as $s) +-$db2->Execute($s); +-?> +\ No newline at end of file +diff -urN moodle/lib/adodb/tests/time.php moodle.adodb/lib/adodb/tests/time.php +--- moodle/lib/adodb/tests/time.php 2003-10-22 04:52:42.000000000 -0400 ++++ moodle.adodb/lib/adodb/tests/time.php 1969-12-31 19:00:00.000000000 -0500 +@@ -1,17 +0,0 @@ +- +- +\ No newline at end of file +diff -urN moodle/lib/adodb/tests/tmssql.php moodle.adodb/lib/adodb/tests/tmssql.php +--- moodle/lib/adodb/tests/tmssql.php 2005-11-10 21:05:25.000000000 -0500 ++++ moodle.adodb/lib/adodb/tests/tmssql.php 2006-01-03 21:07:46.000000000 -0500 +@@ -1,65 +1,10 @@ + mssql"; +- $db = mssql_connect('JAGUAR\vsdotnet','adodb','natsoft') or die('No Connection'); +- mssql_select_db('northwind',$db); +- +- $rs = mssql_query('select getdate() as date',$db); +- $o = mssql_fetch_row($rs); +- print_r($o); +- mssql_free_result($rs); +- +- print "
Delete
"; flush(); +- $rs2 = mssql_query('delete from adoxyz',$db); +- $p = mssql_num_rows($rs2); +- mssql_free_result($rs2); ++require_once('../../../config.php'); ++require_once('../../weblib.php'); + +-} ++add_to_log(0, 'adodb', 'intrusion attempt', 'lib/adodb/tests/tmssql.php'); ++trigger_error('SECURITY WARNING: intrusion attempt against lib/tests/tmssql.php from ' . getremoteaddr()); ++error('SECURITY WARNING: logged intrusion attempt against lib/adodb/tests/tmssql.php'); + +-function tpear() +-{ +-include_once('DB.php'); +- +- print "Delete
"; flush(); +- $rs = $conn->query('delete from tester'); +- print "date=".$conn->GetOne('select getdate()')."Delete
"; flush(); +- $rs = $conn->Execute('delete from tester'); +- print "date=".$conn->GetOne('select getdate()')."