diff --git a/phpgwapi/inc/adodb/tests/benchmark.php b/phpgwapi/inc/adodb/tests/benchmark.php deleted file mode 100644 index 61b39a000f..0000000000 --- a/phpgwapi/inc/adodb/tests/benchmark.php +++ /dev/null @@ -1,84 +0,0 @@ - - - - - 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; - 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

",$total,$max, sizeof($arr)); - flush(); - - - //$db->Close(); -} -include("testdatabases.inc.php"); - -?> - - - - diff --git a/phpgwapi/inc/adodb/tests/client.php b/phpgwapi/inc/adodb/tests/client.php deleted file mode 100644 index dafdf2c7fa..0000000000 --- a/phpgwapi/inc/adodb/tests/client.php +++ /dev/null @@ -1,194 +0,0 @@ - - -$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/phpgwapi/inc/adodb/tests/pdo.php b/phpgwapi/inc/adodb/tests/pdo.php deleted file mode 100644 index b085549803..0000000000 --- a/phpgwapi/inc/adodb/tests/pdo.php +++ /dev/null @@ -1,82 +0,0 @@ -Connect($connstr,$u,$p) || die("CONNECT FAILED"); - - - echo "$connstr: Execute\n"; - - //$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; - $rs = $DB->Execute("select * from ADOXYZ where id<3"); - echo "*** e=".$DB->ErrorNo() . " ".($DB->ErrorMsg())."\n"; - - - //print_r(get_class_methods($DB->_stmt)); - - if (!$rs) die("NO RS"); - - echo "Meta\n"; - for ($i=0; $i < $rs->NumCols(); $i++) { - var_dump($rs->FetchField($i)); - echo "
"; - } - - echo "FETCH\n"; - $cnt = 0; - while (!$rs->EOF) { - adodb_pr($rs->fields); - $rs->MoveNext(); - if ($cnt++ > 1000) break; - } - - echo "
--------------------------------------------------------
\n\n\n"; - - $stmt = $DB->PrepareStmt("select * from ADOXYZ"); - - $rs = $stmt->Execute(); - $cols = $stmt->NumCols(); // execute required - - echo "COLS = $cols"; - for($i=1;$i<=$cols;$i++) { - $v = $stmt->_stmt->getColumnMeta($i); - var_dump($v); - } - - echo "e=".$stmt->ErrorNo() . " ".($stmt->ErrorMsg())."\n"; - while ($arr = $rs->FetchRow()) { - adodb_pr($arr); - } - die("DONE\n"); - -} catch (exception $e) { - echo "
";
-	echo $e;
-	echo "
"; -} - -?> \ No newline at end of file diff --git a/phpgwapi/inc/adodb/tests/test-datadict.php b/phpgwapi/inc/adodb/tests/test-datadict.php deleted file mode 100644 index ff83762dc9..0000000000 --- a/phpgwapi/inc/adodb/tests/test-datadict.php +++ /dev/null @@ -1,248 +0,0 @@ -$dbType

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

"; -} - -/*** - -Generated SQL: - -mysql - -CREATE DATABASE KUTU; -DROP TABLE KUTU.testtable; -CREATE TABLE KUTU.testtable ( -id INTEGER NOT NULL AUTO_INCREMENT, -firstname VARCHAR(30) DEFAULT 'Joan', -lastname VARCHAR(28) NOT NULL DEFAULT 'Chen', -averylonglongfieldname LONGTEXT NOT NULL, -price NUMERIC(7,2) NOT NULL DEFAULT 0.00, -MYDATE DATE DEFAULT CURDATE(), - PRIMARY KEY (id, lastname) -)TYPE=ISAM; -CREATE FULLTEXT INDEX idx ON KUTU.testtable (firstname,lastname); -CREATE INDEX idx2 ON KUTU.testtable (price,lastname); -ALTER TABLE KUTU.testtable ADD height DOUBLE; -ALTER TABLE KUTU.testtable ADD weight DOUBLE; -ALTER TABLE KUTU.testtable MODIFY COLUMN height DOUBLE NOT NULL; -ALTER TABLE KUTU.testtable MODIFY COLUMN weight DOUBLE NOT NULL; - - --------------------------------------------------------------------------------- - -oci8 - -CREATE USER KUTU IDENTIFIED BY tiger; -/ -GRANT CREATE SESSION, CREATE TABLE,UNLIMITED TABLESPACE,CREATE SEQUENCE TO KUTU; -/ -DROP TABLE KUTU.testtable CASCADE CONSTRAINTS; -/ -CREATE TABLE KUTU.testtable ( -id NUMBER(16) NOT NULL, -firstname VARCHAR(30) DEFAULT 'Joan', -lastname VARCHAR(28) DEFAULT 'Chen' NOT NULL, -averylonglongfieldname CLOB NOT NULL, -price NUMBER(7,2) DEFAULT 0.00 NOT NULL, -MYDATE DATE DEFAULT TRUNC(SYSDATE), - PRIMARY KEY (id, lastname) -)TABLESPACE USERS; -/ -DROP SEQUENCE KUTU.SEQ_testtable; -/ -CREATE SEQUENCE KUTU.SEQ_testtable; -/ -CREATE OR REPLACE TRIGGER KUTU.TRIG_SEQ_testtable BEFORE insert ON KUTU.testtable - FOR EACH ROW - BEGIN - select KUTU.SEQ_testtable.nextval into :new.id from dual; - END; -/ -CREATE BITMAP INDEX idx ON KUTU.testtable (firstname,lastname); -/ -CREATE INDEX idx2 ON KUTU.testtable (price,lastname); -/ -ALTER TABLE testtable ADD ( - height NUMBER, - weight NUMBER); -/ -ALTER TABLE testtable MODIFY( - height NUMBER NOT NULL, - weight NUMBER NOT NULL); -/ - - --------------------------------------------------------------------------------- - -postgres -AlterColumnSQL not supported for PostgreSQL - - -CREATE DATABASE KUTU LOCATION='/u01/postdata'; -DROP TABLE KUTU.testtable; -CREATE TABLE KUTU.testtable ( -id SERIAL, -firstname VARCHAR(30) DEFAULT 'Joan', -lastname VARCHAR(28) DEFAULT 'Chen' NOT NULL, -averylonglongfieldname TEXT NOT NULL, -price NUMERIC(7,2) DEFAULT 0.00 NOT NULL, -MYDATE DATE DEFAULT CURRENT_DATE, - PRIMARY KEY (id, lastname) -); -CREATE INDEX idx ON KUTU.testtable USING HASH (firstname,lastname); -CREATE INDEX idx2 ON KUTU.testtable (price,lastname); -ALTER TABLE KUTU.testtable ADD height FLOAT8; -ALTER TABLE KUTU.testtable ADD weight FLOAT8; - - --------------------------------------------------------------------------------- - -odbc_mssql - -CREATE DATABASE KUTU; -DROP TABLE KUTU.testtable; -CREATE TABLE KUTU.testtable ( -id INT IDENTITY(1,1) NOT NULL, -firstname VARCHAR(30) DEFAULT 'Joan', -lastname VARCHAR(28) DEFAULT 'Chen' NOT NULL, -averylonglongfieldname TEXT NOT NULL, -price NUMERIC(7,2) DEFAULT 0.00 NOT NULL, -MYDATE DATETIME DEFAULT GetDate(), - PRIMARY KEY (id, lastname) -); -CREATE CLUSTERED INDEX idx ON KUTU.testtable (firstname,lastname); -CREATE INDEX idx2 ON KUTU.testtable (price,lastname); -ALTER TABLE KUTU.testtable ADD - height REAL, - weight REAL; -ALTER TABLE KUTU.testtable ALTER COLUMN height REAL NOT NULL; -ALTER TABLE KUTU.testtable ALTER COLUMN weight REAL NOT NULL; - - --------------------------------------------------------------------------------- -*/ - - -echo "

Test XML Schema

"; -$ff = file('xmlschema.xml'); -echo "
";
-foreach($ff as $xml) echo htmlspecialchars($xml);
-echo "
"; -include_once('test-xmlschema.php'); -?> \ No newline at end of file diff --git a/phpgwapi/inc/adodb/tests/test-perf.php b/phpgwapi/inc/adodb/tests/test-perf.php deleted file mode 100644 index bdeae28153..0000000000 --- a/phpgwapi/inc/adodb/tests/test-perf.php +++ /dev/null @@ -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 --git a/phpgwapi/inc/adodb/tests/test-pgblob.php b/phpgwapi/inc/adodb/tests/test-pgblob.php
deleted file mode 100644
index ee1c697cbe..0000000000
--- a/phpgwapi/inc/adodb/tests/test-pgblob.php
+++ /dev/null
@@ -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 --git a/phpgwapi/inc/adodb/tests/test-php5.php b/phpgwapi/inc/adodb/tests/test-php5.php deleted file mode 100644 index 5b073ba8f6..0000000000 --- a/phpgwapi/inc/adodb/tests/test-php5.php +++ /dev/null @@ -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 ?Prepare("select * from adoxyz where ?ErrorMsg(),"\n"; -$rs = $db->Execute($stmt,array(10,20)); - -echo "
Foreach Iterator Test (rand=".rand().")
"; -$i = 0; -foreach($rs as $v) { - $i += 1; - echo "rec $i: "; $s1 = adodb_pr($v,true); $s2 = adodb_pr($rs->fields,true); - if ($s1 != $s2 && !empty($v)) {adodb_pr($s1); adodb_pr($s2);} - else echo "passed
"; - flush(); -} - - -if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n"); -else echo "Count $i is correct
"; - -$rs = $db->Execute("select bad from badder"); - -} catch (exception $e) { - adodb_pr($e); - echo "

adodb_backtrace:

\n"; - $e = adodb_backtrace($e->gettrace()); -} - -$rs = $db->Execute("select distinct id, firstname,lastname from adoxyz order by id"); -echo "Result=\n",$rs; -?> \ No newline at end of file diff --git a/phpgwapi/inc/adodb/tests/test-xmlschema.php b/phpgwapi/inc/adodb/tests/test-xmlschema.php deleted file mode 100644 index 807aefe504..0000000000 --- a/phpgwapi/inc/adodb/tests/test-xmlschema.php +++ /dev/null @@ -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 --git a/phpgwapi/inc/adodb/tests/test.php b/phpgwapi/inc/adodb/tests/test.php deleted file mode 100644 index cf49c94415..0000000000 --- a/phpgwapi/inc/adodb/tests/test.php +++ /dev/null @@ -1,1704 +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; - -?>
-

-
 
-

-Execute('select lastname,firstname,lastname,id from adoxyz'); - $arr = $rs->GetAssoc(); - echo "
";print_r($arr);
-	die();*/
-	
-	GLOBAL $EXECS, $CACHED;
-	
-	$EXECS = 0;
-	$CACHED = 0;
-	//$db->Execute("drop table adodb_logsql");
-	if ((rand()%3) == 0) @$db->Execute("delete from adodb_logsql");
-	$db->debug=1;
-	
-	$db->fnExecute = 'CountExecs';
-	$db->fnCacheExecute = 'CountCachedExecs';
-	
-	if (empty($_GET['nolog'])) {
-		echo "

SQL Logging enabled

"; - $db->LogSQL();/* - $sql = -"SELECT t1.sid, t1.sid, t1.title, t1.hometext, t1.notes, t1.aid, t1.informant, -t2.url, t2.email, t1.catid, t3.title, t1.topic, t4.topicname, t4.topicimage, -t4.topictext, t1.score, t1.ratings, t1.counter, t1.comments, t1.acomm -FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_topics` `t4` - WHERE ((t2.aid=t1.aid) AND (t3.catid=t1.catid) AND (t4.topicid=t1.topic) - AND ((t1.alanguage='german') OR (t1.alanguage='')) AND (t1.ihome='0')) - ORDER BY t1.time DESC"; - $db->SelectLimit($sql); - echo $db->ErrorMsg();*/ - } - $ADODB_CACHE_DIR = dirname(TempNam('/tmp','testadodb')); - $db->debug = false; - //print $db->UnixTimeStamp('2003-7-22 23:00:00'); - - $phpv = phpversion(); - if (defined('ADODB_EXTENSION')) $ext = '   Extension '.ADODB_EXTENSION.' installed'; - else $ext = ''; - print "

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

"; - flush(); - - - $arr = $db->ServerInfo(); - print_r($arr); - echo "
"; - $e = error_reporting(E_ALL-E_WARNING); - flush(); - - $tt = $db->Time(); - if ($tt == 0) echo '
$db->Time failed'; - else echo "
db->Time: ".date('d-m-Y H:i:s',$tt); - echo '
'; - - echo "Date=",$db->UserDate('2002-04-07'),'
'; - print "date1 (1969-02-20) = ".$db->DBDate('1969-2-20'); - print "
date1 (1999-02-20) = ".$db->DBDate('1999-2-20'); - print "
date1.1 1999 = ".$db->DBDate("'1999'"); - print "
date2 (1970-1-2) = ".$db->DBDate(24*3600)."

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

"; - print "
ts4 =".($db->UnixTimeStamp("19700101000101")+8*3600); - print "
ts5 =".$db->DBTimeStamp($db->UnixTimeStamp("20040110092123")); - print "
ts6 =".$db->UserTimeStamp("20040110092123"); - print "
ts7 =".$db->DBTimeStamp("20040110092123"); - flush(); - // mssql too slow in failing bad connection - if (false && $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); - flush(); - - //$ADODB_COUNTRECS=false; - $rs=$db->Execute('select * from adoxyz order by id'); - if($rs === false) $create = true; - else $rs->Close(); - - //if ($db->databaseType !='vfp') $db->Execute("drop table ADOXYZ"); - - if ($create) { - if (false && $db->databaseType == 'ibase') { - print "Please create the following table for testing:

$createtab

"; - return; - } else { - $db->debug = 99; - $e = error_reporting(E_ALL-E_WARNING); - $db->Execute($createtab); - error_reporting($e); - } - } - - echo "

Testing Metatypes

"; - $t = $db->MetaType('varchar'); - if ($t != 'C') Err("Bad Metatype for varchar"); - - $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, FetchField when EOF, and GetInsertSQL

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

"; - if ($rs->EOF && (($ox = $rs->FetchField(0)) && !empty($ox->name))) { - $record['id'] = 99; - $record['firstname'] = 'John'; - $sql = $db->GetInsertSQL($rs, $record); - if (strtoupper($sql) != strtoupper("INSERT INTO ADOXYZ ( id, firstname ) VALUES ( 99, 'John' )")) Err("GetInsertSQL does not work on empty table: $sql"); - } else { - Err("FetchField does not work on empty recordset, meaning GetInsertSQL will fail..."); - } - if ($rs) $rs->Close(); - flush(); - //$db->debug=true; - print "

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

'; - if ($db->hasTransactions) Err("hasTransactions should be false"); - } else { /* COMMIT */ - if (!$db->hasTransactions) Err("hasTransactions should be true"); - if ($db->transCnt != 1) Err("Invalid transCnt = $db->transCnt (should be 1)"); - $rs = $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values (99,'Should Not','Exist (Commit)',$time)"); - if ($rs && $db->CommitTrans()) { - $rs->Close(); - $rs = &$db->Execute("select * from ADOXYZ where id=99"); - 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 { - if (!$rs) { - print "Insert failed

"; - $db->RollbackTrans(); - } else print "Commit failed

"; - } - if ($db->transCnt != 0) Err("Invalid transCnt = $db->transCnt (should be 0)"); - - /* ROLLBACK */ - if (!$db->BeginTrans()) print "

Error in BeginTrans()

"; - print "

Testing Rollback: "; - $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values (100,'Should Not','Exist (Rollback)',$time)"); - if ($db->RollbackTrans()) { - $rs = $db->Execute("select * from ADOXYZ where id=100"); - if ($rs && !$rs->EOF) print '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 ($db->transCnt != 0) Err("Invalid transCnt = $db->transCnt (should be 0)"); - } - - 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 and views: "; - foreach($a as $v) print " ($v) "; - print '

'; - } - - $a = $db->MetaTables('VIEW'); - if ($a===false) print "MetaTables not supported (views)

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

'; - } - - $a = $db->MetaTables(false,false,'aDo%'); - if ($a===false) print "MetaTables not supported (mask)

"; - else { - print "Array of ado%: "; - foreach($a as $v) print " ($v) "; - print '

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

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

'; - } - - $db->debug=0; - $rez = $db->MetaColumns("NOSUCHTABLEHERE"); - if ($rez !== false) { - Err("MetaColumns error handling failed"); - var_dump($rez); - } - $db->debug=1; - $a = $db->MetaColumns('ADOXYZ'); - if ($a===false) print "MetaColumns not supported

"; - else { - print "

Columns of ADOXYZ:
"; - foreach($a as $v) {print_r($v); echo "
";} - echo "
"; - } - - print "

Testing MetaIndexes

"; - - $a = $db->MetaIndexes(('ADOXYZ'),true); - if ($a===false) print "MetaIndexes not supported

"; - else { - print "

Indexes of ADOXYZ:
"; - adodb_pr($a); - echo "
"; - } - print "

Testing MetaPrimaryKeys

"; - $a = $db->MetaPrimaryKeys('ADOXYZ'); - var_dump($a); - } - $rs = &$db->Execute('delete from ADOXYZ'); - if ($rs) $rs->Close(); - - $db->debug = false; - - - switch ($db->databaseType) { - case 'vfp': - - if (0) { - // memo test - $rs = $db->Execute("select data from memo"); - rs2html($rs); - } - break; - - case 'postgres7': - case 'postgres64': - case 'postgres': - case 'ibase': - print "

Encode=".$db->BlobEncode("abc\0d\"' -ef")."

";//' - - print "

Testing Foreign Keys

"; - $arr = $db->MetaForeignKeys('adoxyz',false,true); - print_r($arr); - if (!$arr) Err("Bad MetaForeignKeys"); - break; - - case 'odbc_mssql': - case 'mssqlpo': - print "

Testing Foreign Keys

"; - $arr = $db->MetaForeignKeys('Orders',false,true); - print_r($arr); - if (!$arr) Err("Bad MetaForeignKeys"); - if ($db->databaseType == 'odbc_mssql') break; - - case '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 - - -CREATE PROCEDURE ADODBTestSP -@a nvarchar(25) -AS -SELECT GETDATE() AS T, @a AS A -GO -*/ - print "

Testing Stored Procedures for mssql

"; - $saved = $db->debug; - $db->debug=true; - - $cmd = $db->PrepareSP('ADODBTestSP'); - $ss = "You should see me in the output."; - $db->InParameter($cmd,$ss,'a'); - $rs = $db->Execute($cmd); - echo $rs->fields['T']." --- ".$rs->fields['A']."---
"; - - $cat = 'Dairy Products'; - $yr = '1998'; - - $stmt = $db->PrepareSP('SalesByCategory'); - $db->InParameter($stmt,$cat,'CategoryName'); - $db->InParameter($stmt,$yr,'OrdYear'); - $rs = $db->Execute($stmt); - rs2html($rs); - - $cat = 'Grains/Cereals'; - $yr = 1998; - - $stmt = $db->PrepareSP('SalesByCategory'); - $db->InParameter($stmt,$cat,'CategoryName'); - $db->InParameter($stmt,$yr,'OrdYear'); - $rs = $db->Execute($stmt); - rs2html($rs); - - /* - Test out params - works in PHP 4.2.3 and 4.3.3 and 4.3.8 but not 4.3.0: - - CREATE PROCEDURE at_date_interval - @days INTEGER, - @start VARCHAR(20) OUT, - @end VARCHAR(20) OUT - AS - BEGIN - set @start = CONVERT(VARCHAR(20), getdate(), 101) - set @end =CONVERT(VARCHAR(20), dateadd(day, @days, getdate()), 101 ) - END - GO - */ - $db->debug=1; - $stmt = $db->PrepareSP('at_date_interval'); - $days = 10; - $begin_date = ''; - $end_date = ''; - $db->InParameter($stmt,$days,'days', 4, SQLINT4); - $db->OutParameter($stmt,$begin_date,'start', 20, SQLVARCHAR ); - $db->OutParameter($stmt,$end_date,'end', 20, SQLVARCHAR ); - $db->Execute($stmt); - if (empty($begin_date) or empty($end_date) or $begin_date == $end_date) { - Err("MSSQL SP Test for OUT Failed"); - print "begin=$begin_date end=$end_date

"; - } else print "(Today +10days) = (begin=$begin_date end=$end_date)

"; - - $db->debug = $saved; - break; - case 'oci8': - case 'oci8po': - - if (0) { - $t = getmicrotime(); - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - $arr = $db->GetArray('select * from abalone_tree'); - $arr = $db->GetArray('select * from abalone_tree'); - $arr = $db->GetArray('select * from abalone_tree'); - echo "

t = ",getmicrotime() - $t,"

"; - die(); - } - - # cleanup - $db->Execute("delete from photos where id=99 or id=1"); - $db->Execute("insert into photos (id) values(1)"); - $db->Execute("update photos set photo=null,descclob=null where id=1"); - - $saved = $db->debug; - $db->debug=true; - - - - /* - CREATE TABLE PHOTOS - ( - ID NUMBER(16), - PHOTO BLOB, - DESCRIPTION VARCHAR2(4000 BYTE), - DESCCLOB CLOB - ); - - INSERT INTO PHOTOS (ID) VALUES(1); - */ - $s = ''; - for ($i = 0; $i <= 500; $i++) { - $s .= '1234567890'; - } - - $sql = "INSERT INTO photos ( ID, photo) ". - "VALUES ( :id, empty_blob() )". - " RETURNING photo INTO :xx"; - - - $blob_data = $s; - $id = 99; - - $stmt = $db->PrepareSP($sql); - $db->InParameter($stmt, $id, 'id'); - $blob = $db->InParameter($stmt, $s, 'xx',-1, OCI_B_BLOB); - $db->StartTrans(); - $result = $db->Execute($stmt); - $db->CompleteTrans(); - - $s2= $db->GetOne("select photo from photos where id=99"); - echo "
---$s2"; - if ($s !== $s2) Err("insert blob does not match"); - - print "

Testing Blob: size=".strlen($s)."

"; - $ok = $db->Updateblob('photos','photo',$s,'id=1'); - if (!$ok) Err("Blob failed 1"); - else { - $s2= $db->GetOne("select photo from photos where id=1"); - if ($s !== $s2) Err("updateblob does not match"); - } - - print "

Testing Clob: size=".strlen($s)."

"; - $ok = $db->UpdateClob('photos','descclob',$s,'id=1'); - if (!$ok) Err("Clob failed 1"); - else { - $s2= $db->GetOne("select descclob from photos where id=1"); - if ($s !== $s2) Err("updateclob does not match"); - } - - - $s = ''; - $s2 = ''; - print "

Testing Foreign Keys

"; - $arr = $db->MetaForeignKeys('emp','scott'); - print_r($arr); - if (!$arr) Err("Bad MetaForeignKeys"); -/* --- TEST PACKAGE --- "Set scan off" turns off substitution variables. -Set scan off; - -CREATE OR REPLACE PACKAGE Adodb AS -TYPE TabType IS REF CURSOR RETURN TAB%ROWTYPE; -PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames IN VARCHAR); -PROCEDURE open_tab2 (tabcursor IN OUT TabType,tablenames IN OUT VARCHAR) ; -PROCEDURE data_out(input IN VARCHAR, output OUT VARCHAR); -PROCEDURE data_in(input IN VARCHAR); -PROCEDURE myproc (p1 IN NUMBER, p2 OUT NUMBER); -END Adodb; -/ - - -CREATE OR REPLACE PACKAGE BODY Adodb AS -PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames IN VARCHAR) IS - BEGIN - OPEN tabcursor FOR SELECT * FROM TAB WHERE tname LIKE tablenames; - END open_tab; - - PROCEDURE open_tab2 (tabcursor IN OUT TabType,tablenames IN OUT VARCHAR) IS - BEGIN - OPEN tabcursor FOR SELECT * FROM TAB WHERE tname LIKE tablenames; - tablenames := 'TEST'; - END open_tab2; - -PROCEDURE data_out(input IN VARCHAR, output OUT VARCHAR) IS - BEGIN - output := 'Cinta Hati '||input; - END; - -PROCEDURE data_in(input IN VARCHAR) IS - ignore varchar(1000); - BEGIN - ignore := input; - END; - -PROCEDURE myproc (p1 IN NUMBER, p2 OUT NUMBER) AS -BEGIN -p2 := p1; -END; -END Adodb; -/ - -*/ - - print "

Testing Cursor Variables

"; - $rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:zz,'A%'); END;",'zz'); - - if ($rs && !$rs->EOF) { - $v = $db->GetOne("SELECT count(*) FROM tab where tname like 'A%'"); - if ($v == $rs->RecordCount()) print "Test 1 RowCount: OK

"; - else Err("Test 1 RowCount ".$rs->RecordCount().", actual = $v"); - } else { - print "Error in using Cursor Variables 1

"; - } - $rs->Close(); - - print "

Testing Stored Procedures for oci8

"; - - $stmt = $db->PrepareSP("BEGIN adodb.data_out(:a1, :a2); END;"); - $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); - - $stmt = $db->PrepareSP("begin adodb.data_in(:a1); end;"); - $db->InParameter($stmt,$a1,'a1'); - $db->Execute($stmt); - - $db->debug = $saved; - break; - - default: - break; - } - $arr = array( - array(1,'Caroline','Miranda'), - array(2,'John','Lim'), - array(3,'Wai Hun','See') - ); - //$db->debug=1; - print "

Testing Bulk Insert of 3 rows

"; - - $sql = "insert into ADOXYZ (id,firstname,lastname) values (".$db->Param('0').",".$db->Param('1').",".$db->Param('2').")"; - $db->StartTrans(); - $db->Execute($sql,$arr); - $db->CompleteTrans(); - $rs = $db->Execute('select * from ADOXYZ order by id'); - if (!$rs || $rs->RecordCount() != 3) Err("Bad bulk insert"); - - rs2html($rs); - - $db->Execute('delete from ADOXYZ'); - - print "

Inserting 50 rows

"; - - for ($i = 0; $i < 5; $i++) { - - $time = $db->DBDate(time()); - if (empty($_GET['hide'])) $db->debug = true; - switch($db->databaseType){ - case 'mssqlpo': - case 'mssql': - $sqlt = "CREATE TABLE mytable ( - row1 INT IDENTITY(1,1) NOT NULL, - row2 varchar(16), - PRIMARY KEY (row1))"; - //$db->debug=1; - if (!$db->Execute("delete from mytable")) - $db->Execute($sqlt); - - $ok = $db->Execute("insert into mytable (row2) values ('test')"); - $ins_id=$db->Insert_ID(); - echo "Insert ID=";var_dump($ins_id); - if ($ins_id == 0) Err("Bad Insert_ID()"); - $ins_id2 = $db->GetOne("select row1 from mytable"); - if ($ins_id != $ins_id2) Err("Bad Insert_ID() 2"); - - $arr = array(0=>'Caroline',1=>'Miranda'); - $sql = "insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+0,?,?,$time)"; - break; - case 'mysqli': - case 'mysqlt': - case 'mysql': - $sqlt = "CREATE TABLE `mytable` ( - `row1` int(11) NOT NULL auto_increment, - `row2` varchar(16) NOT NULL default '', - PRIMARY KEY (`row1`), - KEY `myindex` (`row1`,`row2`) -) "; - if (!$db->Execute("delete from mytable")) - $db->Execute($sqlt); - - $ok = $db->Execute("insert into mytable (row2) values ('test')"); - $ins_id=$db->Insert_ID(); - echo "Insert ID=";var_dump($ins_id); - if ($ins_id == 0) Err("Bad Insert_ID()"); - $ins_id2 = $db->GetOne("select row1 from mytable"); - if ($ins_id != $ins_id2) Err("Bad Insert_ID() 2"); - - 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'); - $amt = rand() % 100; - $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) Err( '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)"); - /*$ins_id=$db->Insert_ID(); - echo "Insert ID=";var_dump($ins_id);*/ - if ($db->databaseType == 'mysql') if ($ins_id == 0) Err('Bad Insert_ID'); - $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',".$db->quote("Turing'ton").",$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 )"); - } // for - if (1) { - $db->debug=1; - $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; - $cnt = $db->GetOne("select count(*) from ADOXYZ"); - $rs = $db->Execute('update ADOXYZ set id=id+1'); - if (!is_object($rs)) { - print_r($rs); - err("Update should return object"); - } - if (!$rs) err("Update generated error"); - - $nrows = $db->Affected_Rows(); - if ($nrows === false) print "

Affected_Rows() not supported

"; - else if ($nrows != $cnt) print "

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

"; - else print "

Affected_Rows() passed

"; - } - - /*if ($db->dataProvider == 'oci8') */ $array = array('zid'=>1,'zdate'=>date('Y-m-d',time())); - /*else $array=array(1,date('Y-m-d',time()));*/ - - $id = $db->GetOne("select id from ADOXYZ - where id=".$db->Param('zid')." and created>=".$db->Param('ZDATE')."", - $array); - if ($id != 1) Err("Bad bind; id=$id"); - else echo "
Bind date/integer passed"; - - $db->debug = false; - $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; - ////////////////////////////////////////////////////////////////////////////////////////// - - $rs = $db->Execute("select * from ADOXYZ where firstname = 'not known'"); - if (!$rs || !$rs->EOF) print "

Error on empty recordset

"; - else if ($rs->RecordCount() != 0) { - print "

Error on RecordCount. Should be 0. Was ".$rs->RecordCount()."

"; - print_r($rs->fields); - } - if ($db->databaseType !== 'odbc') { - $rs = &$db->Execute("select id,firstname,lastname,created,".$db->random." from ADOXYZ order by id"); - if ($rs) { - if ($rs->RecordCount() != 50) { - print "

RecordCount returns ".$rs->RecordCount().", should be 50

"; - adodb_pr($rs->GetArray()); - $poc = $rs->PO_RecordCount('ADOXYZ'); - if ($poc == 50) print "

    PO_RecordCount passed

"; - else print "

PO_RecordCount returns wrong value: $poc

"; - } else print "

RecordCount() passed

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

The fields columns can be indexed by column name.

'; - else { - Err( '

The fields columns cannot be indexed by column name.

'); - print_r($rs->fields); - } - if (empty($_GET['hide'])) rs2html($rs); - } - else print "

Error in Execute of SELECT with random

"; - } - $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 ($rs) { - 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; - } - } - } else { - print "

Failed rs

"; - die("

ADOXYZ table cannot be read - die()"); - } - $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; - print "

FetchObject/FetchNextObject Test 2

"; - #$db->debug=99; - $rs = $db->Execute('select * from ADOXYZ'); - if (empty($rs->connection)) print "Connection object missing from recordset
"; - print_r($rs->fields); - 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

"; - $db->debug=1; - $rs = $db->CacheSelectLimit(' select id, firstname from ADOXYZ order by id',2); - - if ($rs && !$rs->EOF) { - if (isset($rs->fields[0])) { - Err("ASSOC has numeric fields"); - print_r($rs->fields); - } - if ($rs->fields['id'] != 1) {Err("Error"); print_r($rs->fields);}; - if (trim($rs->fields['firstname']) != 'Caroline') {print Err("Error 2"); print_r($rs->fields);}; - - $rs->MoveNext(); - if ($rs->fields['id'] != 2) {Err("Error 3"); print_r($rs->fields);}; - $rs->MoveNext(); - if (!$rs->EOF) { - Err("Error EOF"); - print_r($rs); - } - } - - 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 (ADODB_ASSOC_CASE == 2) { - $id = 'ID'; - $fname = 'FIRSTNAME'; - }else { - $id = 'id'; - $fname = 'firstname'; - } - if ($rs->fields[$id] != 1) {Err("Error 1"); print_r($rs->fields);}; - if (trim($rs->fields[$fname]) != 'Caroline') {Err("Error 2"); print_r($rs->fields);}; - $rs->MoveNext(); - if ($rs->fields[$id] != 2) {Err("Error 3"); print_r($rs->fields);}; - $rs->MoveNext(); - if (!$rs->EOF) Err("Error EOF"); - else if (is_array($rs->fields) || $rs->fields) { - Err("Error: ## fields should be set to false on EOF"); - print_r($rs->fields); - } - } - - $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 (isset($rs->fields['id'])) Err("FETCH_NUM has ASSOC fields"); - if ($rs->fields[0] != 1) {Err("Error 1"); print_r($rs->fields);}; - if (trim($rs->fields[1]) != 'Caroline') {Err("Error 2");print_r($rs->fields);}; - $rs->MoveNext(); - if (!$rs->EOF) Err("Error EOF"); - - } - $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) {Err("Error 1");print_r($arr);}; - if (trim($arr['FIRSTNAME']) != 'Caroline') {Err("Error 2"); print_r($arr);}; - $rs->MoveNext(); - if (!$rs->EOF) Err("Error EOF"); - - } - 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) {Err("Error 1"); print_r($arr);}; - if (trim($arr['firstname']) != 'Caroline') {Err("Error 2"); print_r($arr);}; - - } - - print "

GetCol Test

"; - $col = $db->GetCol('select distinct firstname from adoxyz order by 1'); - if (!is_array($col)) Err("Col size is wrong"); - if (trim($col[0]) != 'Alan' or trim($col[9]) != 'Yat Sun') Err("Col elements wrong"); - - $db->debug = true; - - - echo "

Date Update Test

"; - $zdate = date('Y-m-d',time()+3600*24); - $zdate = $db->DBDate($zdate); - $db->Execute("update ADOXYZ set created=$zdate where id=1"); - $row = $db->GetRow("select created,firstname from ADOXYZ where id=1"); - print_r($row); echo "
"; - - - - print "

SelectLimit Distinct 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') Err("Error 1 (exp Caroline), ".$rs->fields[1]); - $rs->MoveNext(); - - if (trim($rs->fields[1]) != 'John') Err("Error 2 (exp John), ".$rs->fields[1]); - $rs->MoveNext(); - if (trim($rs->fields[1]) != 'Mary') Err("Error 3 (exp Mary),".$rs->fields[1]); - $rs->MoveNext(); - if (! $rs->EOF) Err("Error EOF"); - //rs2html($rs); - } else Err("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') Err("Error 1 - No Mary, instead: ".$rs->fields[1]); - $rs->MoveNext(); - if (trim($rs->fields[1]) != 'George')Err("Error 2 - No George, instead: ".$rs->fields[1]); - $rs->MoveNext(); - if (trim($rs->fields[1]) != 'Mr. Alan') Err("Error 3 - No Mr. Alan, instead: ".$rs->fields[1]); - $rs->MoveNext(); - if (! $rs->EOF) Err("Error EOF"); - // rs2html($rs); - } - else Err("Failed SelectLimit Test 2 ". ($rs ? 'EOF':'no RS')); - - print "

SelectLimit Test 3: Should see Wai Hun and Steven

"; - $db->debug=1; - global $A; $A=1; - $rs = &$db->SelectLimit('select * from ADOXYZ order by id',-1,48); - $A=0; - if ($rs && !$rs->EOF) { - if (empty($rs->connection)) print "Connection object missing from recordset
"; - if (trim($rs->fields[1]) != 'Wai Hun') Err("Error 1 ".$rs->fields[1]); - $rs->MoveNext(); - if (trim($rs->fields[1]) != 'Steven') Err("Error 2 ".$rs->fields[1]); - $rs->MoveNext(); - if (! $rs->EOF) { - Err("Error EOF"); - } - //rs2html($rs); - } - else Err("Failed SelectLimit Test 3"); - $db->debug = false; - - - $rs = &$db->Execute("select * from ADOXYZ order by id"); - print "

Testing Move()

"; - if (!$rs)Err( "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

"; - } 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
"; - if ($rs->EOF) Err("Move(7) is EOF already"); - $rs->MoveLast(); - if (trim($rs->Fields("firstname")) != 'Steven'){ - print '

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

"; - print_r($rs); - }else print "MoveLast() OK
"; - $rs->MoveNext(); - if (!$rs->EOF) err("Bad MoveNext"); - if ($rs->canSeek) { - $rs->Move(3); - if (trim($rs->Fields("firstname")) != 'George') { - print '

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

"; - - } else print "Move(3) after MoveLast() OK
"; - } - - print "

Empty Move Test"; - $rs = $db->Execute("select * from ADOXYZ where id > 0 and id < 0"); - $rs->MoveFirst(); - if (!$rs->EOF || $rs->fields) Err("Error in empty move first"); - } - } - - $rs = $db->Execute('select * from ADOXYZ where id = 2'); - if ($rs->EOF || !is_array($rs->fields)) Err("Error in select"); - $rs->MoveNext(); - if (!$rs->EOF) Err("Error in EOF (xx) "); - // $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') { - $sql = "select ".$db->Concat('cast(firstname as varchar)',$db->qstr(' '),'lastname')." as fullname,id,".$db->sysTimeStamp." as d from ADOXYZ"; - $rs = &$db->Execute($sql); - } else { - $sql = "select distinct ".$db->Concat('firstname',$db->qstr(' '),'lastname')." as fullname,id,".$db->sysTimeStamp." as d from ADOXYZ"; - $rs = &$db->Execute($sql); - } - if ($rs) { - if (empty($_GET['hide'])) rs2html($rs); - } else { - Err( "Failed Concat:".$sql); - } - $ADODB_FETCH_MODE = $save; - print "
Testing GetArray() "; - //$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; - - $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
"; - } - - $arr = $db->GetArray("select x from ADOXYZ"); - $e = $db->ErrorMsg(); $e2 = $db->ErrorNo(); - echo "Testing error handling, should see illegal column 'x' error=$e ($e2)
"; - if (!$e || !$e2) Err("Error handling did not work"); - 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
"; - - $stmt = $db->Prepare("select * from ADOXYZ where id < 3"); - $rs = $db->Execute($stmt); - if (!$rs) Err("Prepare failed"); - else { - $arr = $rs->GetArray(); - if (!$arr) Err("Prepare failed 2"); - if (sizeof($arr) != 2) Err("Prepare failed 3"); - } - print "Testing GetAssoc() "; - $savecrecs = $ADODB_COUNTRECS; - $ADODB_COUNTRECS = false; - //$arr = $db->GetArray("select lastname,firstname from ADOXYZ"); - //print_r($arr); - print "
"; - $rs =& $db->Execute("select distinct lastname,firstname,created from ADOXYZ"); - - if ($rs) { - $arr = $rs->GetAssoc(); - //print_r($arr); - if (empty($arr['See']) || trim(reset($arr['See'])) != 'Wai Hun') print $arr['See']."   ERROR
"; - else print " OK 1"; - } - - $arr = &$db->GetAssoc("select distinct lastname,firstname from ADOXYZ"); - if ($arr) { - //print_r($arr); - if (empty($arr['See']) || trim($arr['See']) != 'Wai Hun') print $arr['See']."   ERROR
"; - else print " OK 2
"; - } - // Comment this out to test countrecs = false - $ADODB_COUNTRECS = $savecrecs; - $db->debug=1; - $query = $db->Prepare("select count(*) from ADOXYZ"); - $rs = $db->CacheExecute(10,$query); - if (reset($rs->fields) != 50) echo Err("$cnt wrong for Prepare/CacheGetOne"); - - 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 GetMenu3()
"; - $rs = $db->Execute("select ".$db->Concat('firstname',"'-'",'id').",id, lastname from ADOXYZ order by lastname,id"); - print "Grouped Menu: ".$rs->GetMenu3('name'); - 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(6,"select distinct firstname,lastname from ADOXYZ"); - if ($rs) print ' No blanks, Steven selected: '. $rs->GetMenu2('menu',('Oey'),false).'
'; - else print " Fail
"; - } - echo "

CacheEXecute

"; - - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - $rs = &$db->CacheExecute(6,"select distinct firstname,lastname from ADOXYZ"); - print_r($rs->fields); echo $rs->fetchMode;echo "
"; - echo $rs->Fields('firstname'); - - $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; - $rs = &$db->CacheExecute(6,"select distinct firstname,lastname from ADOXYZ"); - print_r($rs->fields);echo "
"; - echo $rs->Fields('firstname'); - $db->debug = false; - - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - // phplens - - $sql = 'select * from ADOXYZ where 0=1'; - echo "

**Testing '$sql' (phplens compat 1)

"; - $rs = &$db->Execute($sql); - if (!$rs) err( "No recordset returned for '$sql'"); - if (!$rs->FieldCount()) err( "No fields returned for $sql"); - if (!$rs->FetchField(1)) err( "FetchField failed for $sql"); - - $sql = 'select * from ADOXYZ order by 1'; - echo "

**Testing '$sql' (phplens compat 2)

"; - $rs = &$db->Execute($sql); - if (!$rs) err( "No recordset returned for '$sql'
".$db->ErrorMsg()."
"); - - - $sql = 'select * from ADOXYZ order by 1,1'; - echo "

**Testing '$sql' (phplens compat 3)

"; - $rs = &$db->Execute($sql); - if (!$rs) err( "No recordset returned for '$sql'
".$db->ErrorMsg()."
"); - - - // Move - $rs1 = &$db->Execute("select id from ADOXYZ where id <= 2 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($db->databaseType.'abcseq6' ,5), ") "; - if ($val == 0) Err("GenID not supported"); - - if ($val) { - $db->DropSequence('abc_seq2'); - $db->CreateSequence('abc_seq2'); - $val = $db->GenID('abc_seq2'); - $db->DropSequence('abc_seq2'); - $db->CreateSequence('abc_seq2'); - $val = $db->GenID('abc_seq2'); - if ($val != 1) Err("Drop and Create Sequence not supported ($val)"); - } - echo "

"; - - if (substr($db->dataProvider,0,3) != 'notused') { // used to crash 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'); - if ($ee = $db->ErrorMsg()) { - Err("Error message=$ee"); - } - if ($ee = $db->ErrorNo()) { - Err("Error No = $ee"); - } - print_r($rs->fields); - 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]})

"; - - print_r($rs->FetchField(0)); - print time(); - $db->debug=$saved; - } else { - print "

\$db->sysDate not defined

"; - } - - print "

Test CSV

"; - include_once('../toexport.inc.php'); - //$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; - $rs = $db->SelectLimit('select id,firstname,lastname,created,\'He, he\' he,\'"\' q from adoxyz',10); - - print "
";
-	print rs2csv($rs);
-	print "
"; - - $rs = $db->SelectLimit('select id,firstname,lastname,created,\'The "young man", he said\' from adoxyz',10); - - if (PHP_VERSION < 5) { - print "
";
-		rs2tabout($rs);
-		print "
"; - } - //print " CacheFlush "; - //$db->CacheFlush(); - $date = $db->SQLDate('d-m-M-Y-\QQ h:i:s A'); - $sql = "SELECT $date from ADOXYZ"; - print "

Test SQLDate: ".htmlspecialchars($sql)."

"; - $rs = $db->SelectLimit($sql,1); - $d = date('d-m-M-Y-').'Q'.(ceil(date('m')/3.0)).date(' h:i:s A'); - if (!$rs) Err("SQLDate query returned no recordset"); - else if ($d != $rs->fields[0]) Err("SQLDate 1 failed expected:
act:$d
sql:".$rs->fields[0]); - - $date = $db->SQLDate('d-m-M-Y-\QQ h:i:s A',$db->DBDate("1974-02-25")); - $sql = "SELECT $date from ADOXYZ"; - print "

Test SQLDate: ".htmlspecialchars($sql)."

"; - $rs = $db->SelectLimit($sql,1); - $ts = ADOConnection::UnixDate('1974-02-25'); - $d = date('d-m-M-Y-',$ts).'Q'.(ceil(date('m',$ts)/3.0)).date(' h:i:s A',$ts); - if (!$rs) { - Err("SQLDate query returned no recordset"); - echo $db->ErrorMsg(),'
'; - } else if ($d != $rs->fields[0]) Err("SQLDate 2 failed expected:
act:$d
sql:".$rs->fields[0]); - - - print "

Test Filter

"; - $db->debug = 1; - - $rs = $db->SelectLimit('select * from ADOXYZ where id < 3 order by id'); - - $rs = RSFilter($rs,'do_strtolower'); - if (trim($rs->fields[1]) != 'caroline' && trim($rs->fields[2]) != 'miranda') { - err('**** RSFilter failed'); - print_r($rs->fields); - } - - rs2html($rs); - - $db->debug=1; - - - print "

Test Replace

"; - - $ret = $db->Replace('adoxyz', - array('id'=>1,'firstname'=>'Caroline','lastname'=>'Miranda'), - array('id'), - $autoq = true); - if (!$ret) echo "

Error in replacing existing record

"; - else { - $saved = $db->debug; - $db->debug = 0; - $savec = $ADODB_COUNTRECS; - $ADODB_COUNTRECS = true; - $rs = $db->Execute('select * FROM ADOXYZ where id=1'); - $db->debug = $saved; - if ($rs->RecordCount() != 1) { - $cnt = $rs->RecordCount(); - rs2html($rs); - print "Error - Replace failed, count=$cnt

"; - } - $ADODB_COUNTRECS = $savec; - } - $ret = $db->Replace('adoxyz', - array('id'=>1000,'firstname'=>'Harun','lastname'=>'Al-Rashid'), - array('id','firstname'), - $autoq = true); - if ($ret != 2) print "Replace failed: "; - print "test A return value=$ret (2 expected)

"; - - $ret = $db->Replace('adoxyz', - array('id'=>1000,'firstname'=>'Sherazade','lastname'=>'Al-Rashid'), - 'id', - $autoq = true); - if ($ret != 1) - if ($db->dataProvider == 'ibase' && $ret == 2); - else print "Replace failed: "; - print "test B return value=$ret (1 or if ibase then 2 expected)

"; - - print "

rs2rs Test

"; - - $rs = $db->Execute('select * from adoxyz where id>= 1 order by id'); - $rs = $db->_rs2rs($rs); - $rs->valueX = 'X'; - $rs->MoveNext(); - $rs = $db->_rs2rs($rs); - if (!isset($rs->valueX)) err("rs2rs does not preserve array recordsets"); - if (reset($rs->fields) != 1) err("rs2rs does not move to first row: id=".reset($rs->fields)); - - ///////////////////////////////////////////////////////////// - include_once('../pivottable.inc.php'); - print "

Pivot Test

"; - $db->debug=true; - $sql = PivotTableSQL( - $db, # adodb connection - 'adoxyz', # tables - 'firstname', # row fields - 'lastname', # column fields - false, # join - 'ID', # sum - 'Sum ', # label for sum - 'sum', # aggregate function - true - ); - $rs = $db->Execute($sql); - if ($rs) rs2html($rs); - else Err("Pivot sql error"); - - $pear = true; //true; - $db->debug=false; - - if ($pear) { - // PEAR TESTS BELOW - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - - include_once "PEAR.php"; - $rs = $db->query('select * from adoxyz where id>0 and id<10 order by id'); - - $i = 0; - if ($rs && !$rs->EOF) { - while ($arr = $rs->fetchRow()) { - $i++; - //print "$i "; - if ($arr[0] != $i) { - print_r($arr); - print "

PEAR DB emulation error 1.

"; - $pear = false; - break; - } - } - $rs->Close(); - } - - - if ($i != $db->GetOne('select count(*) from adoxyz where id>0 and id<10')) { - print "

PEAR DB emulation error 1.1 EOF ($i)

"; - $pear = false; - } - - $rs = $db->limitQuery('select * from adoxyz where id>0 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.

"; - flush(); - - - $rs = $db->SelectLimit("select ".$db->sysDate." from adoxyz",1); - $date = $rs->fields[0]; - if (!$date) Err("Bad sysDate"); - else { - $ds = $db->UserDate($date,"d m Y"); - if ($ds != date("d m Y")) Err("Bad UserDate: ".$ds.' expected='.date("d m Y")); - else echo "Passed UserDate: $ds

"; - } - $db->debug=1; - if ($db->dataProvider == 'oci8') - $rs = $db->SelectLimit("select to_char(".$db->sysTimeStamp.",'YYYY-MM-DD HH24:MI:SS') from adoxyz",1); - else - $rs = $db->SelectLimit("select ".$db->sysTimeStamp." from adoxyz",1); - $date = $rs->fields[0]; - if (!$date) Err("Bad sysTimeStamp"); - else { - $ds = $db->UserTimeStamp($date,"H \\h\\r\\s-d m Y"); - if ($ds != date("H \\h\\r\\s-d m Y")) Err("Bad UserTimeStamp: ".$ds.", correct is ".date("H \\h\\r\\s-d m Y")); - else echo "Passed UserTimeStamp: $ds

"; - - $date = 100; - $ds = $db->UserTimeStamp($date,"H \\h\\r\\s-d m Y"); - $ds2 = date("H \\h\\r\\s-d m Y",$date); - if ($ds != $ds2) Err("Bad UserTimeStamp 2: $ds: $ds2"); - else echo "Passed UserTimeStamp 2: $ds

"; - } - flush(); - - if ($db->hasTransactions) { - //$db->debug=1; - echo "

Testing StartTrans CompleteTrans

"; - $db->raiseErrorFn = false; - $db->StartTrans(); - $rs = $db->Execute('select * from notable'); - $db->StartTrans(); - $db->BeginTrans(); - $db->Execute("update ADOXYZ set firstname='Carolx' where id=1"); - $db->CommitTrans(); - $db->CompleteTrans(); - $rez = $db->CompleteTrans(); - if ($rez !== false) { - if (is_null($rez)) Err("Error: _transOK not modified"); - else Err("Error: CompleteTrans (1) should have failed"); - } else { - $name = $db->GetOne("Select firstname from ADOXYZ where id=1"); - if ($name == "Carolx") Err("Error: CompleteTrans (2) should have failed"); - else echo "

-- Passed StartTrans test1 - rolling back

"; - } - - $db->StartTrans(); - $db->BeginTrans(); - $db->Execute("update ADOXYZ set firstname='Carolx' where id=1"); - $db->RollbackTrans(); - $rez = $db->CompleteTrans(); - if ($rez !== true) Err("Error: CompleteTrans (1) should have succeeded"); - else { - $name = $db->GetOne("Select firstname from ADOXYZ where id=1"); - if (trim($name) != "Carolx") Err("Error: CompleteTrans (2) should have succeeded, returned name=$name"); - else echo "

-- Passed StartTrans test2 - commiting

"; - } - } - flush(); - $saved = $db->debug; - $db->debug=1; - $cnt = _adodb_getcount($db, 'select * from ADOXYZ where firstname in (select firstname from ADOXYZ)'); - echo "Count= $cnt"; - $db->debug=$saved; - - global $TESTERRS; - $debugerr = true; - - global $ADODB_LANG;$ADODB_LANG = 'fr'; - $db->debug = false; - $TESTERRS = 0; - $db->raiseErrorFn = 'adodb_test_err'; - global $ERRNO; // from adodb_test_err - $db->Execute('select * from nowhere'); - $metae = $db->MetaError($ERRNO); - if ($metae !== DB_ERROR_NOSUCHTABLE) print "

MetaError=".$metae." wrong, should be ".DB_ERROR_NOSUCHTABLE."

"; - else print "

MetaError ok (".DB_ERROR_NOSUCHTABLE."): ".$db->MetaErrorMsg($metae)."

"; - if ($TESTERRS != 1) print "raiseErrorFn select nowhere failed
"; - $rs = $db->Execute('select * from adoxyz'); - if ($debugerr) print " Move"; - $rs->Move(100); - $rs->_queryID = false; - if ($debugerr) print " MoveNext"; - $rs->MoveNext(); - if ($debugerr) print " $rs=false"; - $rs = false; - - flush(); - - print "

SetFetchMode() tests

"; - $db->SetFetchMode(ADODB_FETCH_ASSOC); - $rs = $db->SelectLimit('select firstname from adoxyz',1); - if (!isset($rs->fields['firstname'])) Err("BAD FETCH ASSOC"); - - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - $rs = $db->SelectLimit('select firstname from adoxyz',1); - //var_dump($rs->fields); - if (!isset($rs->fields['firstname'])) Err("BAD FETCH ASSOC"); - - $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; - $db->SetFetchMode(ADODB_FETCH_NUM); - $rs = $db->SelectLimit('select firstname from adoxyz',1); - if (!isset($rs->fields[0])) Err("BAD FETCH NUM"); - - flush(); - - print "

Test MetaTables again with SetFetchMode()

"; - $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; - $db->SetFetchMode(ADODB_FETCH_ASSOC); - print_r($db->MetaTables()); - print "

"; - - //////////////////////////////////////////////////////////////////// - - print "

Testing Bad Connection

"; - flush(); - - if (true || PHP_VERSION < 5) { - if ($db->dataProvider == 'odbtp') $db->databaseType = 'odbtp'; - $conn = NewADOConnection($db->databaseType); - $conn->raiseErrorFn = 'adodb_test_err'; - if (1) $conn->PConnect('abc','baduser','badpassword'); - if ($TESTERRS == 2) print "raiseErrorFn tests passed
"; - else print "raiseErrorFn tests failed ($TESTERRS)
"; - - flush(); - } - //////////////////////////////////////////////////////////////////// - - global $nocountrecs; - - if (isset($nocountrecs) && $ADODB_COUNTRECS) err("Error: \$ADODB_COUNTRECS is set"); - if (empty($nocountrecs) && $ADODB_COUNTRECS==false) err("Error: \$ADODB_COUNTRECS is not set"); - - flush(); -?> -

-
 
-

-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("

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)
"; -} - -//-------------------------------------------------------------------------------------- - - -@set_time_limit(240); // increase timeout - -include("../tohtml.inc.php"); -include("../adodb.inc.php"); -include("../rsfilter.inc.php"); - -/* White Space Check */ - -if (isset($_SERVER['argv'][1])) { - //print_r($_SERVER['argv']); - $_GET[$_SERVER['argv'][1]] = 1; -} - -if (@$_SERVER['COMPUTERNAME'] == 'TIGRESS') { - CheckWS('mysqlt'); - CheckWS('postgres'); - CheckWS('oci8po'); - - CheckWS('firebird'); - CheckWS('sybase'); - if (!ini_get('safe_mode')) CheckWS('informix'); - - CheckWS('ado_mssql'); - CheckWS('ado_access'); - CheckWS('mssql'); - - CheckWS('vfp'); - CheckWS('sqlanywhere'); - CheckWS('db2'); - CheckWS('access'); - CheckWS('odbc_mssql'); - CheckWS('firebird15'); - // - CheckWS('oracle'); - CheckWS('proxy'); - CheckWS('fbsql'); - print "White Space Check complete

"; -} -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; -} -?> - -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
adodb.sourceforge.net.

- -Test GetInsertSQL/GetUpdateSQL   - Sessions   - Paging   - Perf Monitor

-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 --git a/phpgwapi/inc/adodb/tests/test2.php b/phpgwapi/inc/adodb/tests/test2.php deleted file mode 100644 index 169aa0cc62..0000000000 --- a/phpgwapi/inc/adodb/tests/test2.php +++ /dev/null @@ -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 --git a/phpgwapi/inc/adodb/tests/test3.php b/phpgwapi/inc/adodb/tests/test3.php deleted file mode 100644 index 099ec8767e..0000000000 --- a/phpgwapi/inc/adodb/tests/test3.php +++ /dev/null @@ -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 --git a/phpgwapi/inc/adodb/tests/test4.php b/phpgwapi/inc/adodb/tests/test4.php deleted file mode 100644 index 83823e2156..0000000000 --- a/phpgwapi/inc/adodb/tests/test4.php +++ /dev/null @@ -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 --git a/phpgwapi/inc/adodb/tests/test5.php b/phpgwapi/inc/adodb/tests/test5.php deleted file mode 100644 index 8053a33c97..0000000000 --- a/phpgwapi/inc/adodb/tests/test5.php +++ /dev/null @@ -1,47 +0,0 @@ -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/phpgwapi/inc/adodb/tests/test_rs_array.php b/phpgwapi/inc/adodb/tests/test_rs_array.php deleted file mode 100644 index 5c1a51cc06..0000000000 --- a/phpgwapi/inc/adodb/tests/test_rs_array.php +++ /dev/null @@ -1,47 +0,0 @@ -InitArray($array,$typearr); - -while (!$rs->EOF) { - print_r($rs->fields);echo "
"; - $rs->MoveNext(); -} - -echo "
1 Seek
"; -$rs->Move(1); -while (!$rs->EOF) { - print_r($rs->fields);echo "
"; - $rs->MoveNext(); -} - -echo "
2 Seek
"; -$rs->Move(2); -while (!$rs->EOF) { - print_r($rs->fields);echo "
"; - $rs->MoveNext(); -} - -echo "
3 Seek
"; -$rs->Move(3); -while (!$rs->EOF) { - print_r($rs->fields);echo "
"; - $rs->MoveNext(); -} - - - -die(); -?> \ No newline at end of file diff --git a/phpgwapi/inc/adodb/tests/testcache.php b/phpgwapi/inc/adodb/tests/testcache.php deleted file mode 100644 index 2b46cb59ff..0000000000 --- a/phpgwapi/inc/adodb/tests/testcache.php +++ /dev/null @@ -1,29 +0,0 @@ - - -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/phpgwapi/inc/adodb/tests/testdatabases.inc.php b/phpgwapi/inc/adodb/tests/testdatabases.inc.php deleted file mode 100644 index 02bb1bf6c1..0000000000 --- a/phpgwapi/inc/adodb/tests/testdatabases.inc.php +++ /dev/null @@ -1,412 +0,0 @@ - - -
-
-> Access
-> Interbase
-> MSSQL
- > MySQL
-> MySQL ODBC
-> MySQLi -
-
> SQLite
-> MySQL Proxy
-> Oracle (oci8)
-> PostgreSQL
-> PostgreSQL ODBC
-
-> PgSQL PDO
-> MySQL PDO
-> SQLite PDO
-> Access PDO
- -> OCI PDO
- -
> DB2
-> VFP+ODBTP
-> ADO (for mssql and access)
-> $ADODB_COUNTRECS=false
-> No SQL Logging
-> ADOdb time test -
- - - -FETCH MODE IS NOT ADODB_FETCH_DEFAULT"; - -if (isset($nocountrecs)) $ADODB_COUNTRECS = false; - -// cannot test databases below, but we include them anyway to check -// if they parse ok... - -if (!strpos(PHP_VERSION,'5') === 0) { - ADOLoadCode("sybase"); - //ADOLoadCode("postgres"); - //ADOLoadCode("postgres7"); - ADOLoadCode("firebird"); - ADOLoadCode("borland_ibase"); - ADOLoadCode("informix"); - ADOLoadCode("sqlanywhere"); -// ADOLoadCode('mysqli'); -} - - -flush(); -if (!empty($testpostgres)) { - //ADOLoadCode("postgres"); - - $db = &ADONewConnection('postgres'); - print "

Connecting $db->databaseType...

"; - if ($db->Connect("localhost","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, user tester, password test.
".$db->ErrorMsg(); -} - -if (!empty($testpgodbc)) { - - $db = &ADONewConnection('odbc'); - $db->hasTransactions = false; - print "

Connecting $db->databaseType...

"; - - if ($db->PConnect('Postgresql')) { - $db->hasTransactions = true; - testdb($db, - "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) type=innodb"); - } else print "ERROR: PostgreSQL requires a database called test on server, user tester, password test.
".$db->ErrorMsg(); -} - -if (!empty($testibase)) { - //$_GET['nolog'] = true; - $db = &ADONewConnection('firebird'); - print "

Connecting $db->databaseType...

"; - if ($db->PConnect("localhost:d:\\firebird\\151\\examples\\EMPLOYEE.fdb", "sysdba", "masterkey", "")) - testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname char(24),price numeric(12,2),created date)"); - else print "ERROR: Interbase test requires a database called employee.gdb".'
'.$db->ErrorMsg(); - -} - - -if (!empty($testsqlite)) { - $path =urlencode('d:\inetpub\adodb\sqlite.db'); - $dsn = "sqlite://$path/"; - $db = ADONewConnection($dsn); - echo $dsn; - -// $db = &ADONewConnection('sqlite'); - print "

Connecting $db->databaseType...

"; - - if (1) - //if ($db->PConnect("d:\\inetpub\\adodb\\sqlite.db", "", "", "")) - testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)"); - else print "ERROR: SQLite"; - -} - -if (!empty($testpdopgsql)) { - $connstr = "pgsql:dbname=test"; - $u = 'tester';$p='test'; - $db = &ADONewConnection('pdo'); - print "

Connecting $db->databaseType...

"; - $db->Connect($connstr,$u,$p) || die("CONNECT FAILED"); - testdb($db, - "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); -} - -if (!empty($testpdomysql)) { - $connstr = "mysql:dbname=northwind"; - $u = 'root';$p=''; - $db = &ADONewConnection('pdo'); - print "

Connecting $db->databaseType...

"; - $db->Connect($connstr,$u,$p) || die("CONNECT FAILED"); - - testdb($db, - "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); -} - -if (!empty($testpdosqlite)) { - $connstr = "sqlite:d:/inetpub/adodb/sqlite-pdo.db3"; - $u = '';$p=''; - $db = &ADONewConnection('pdo'); - $db->hasTransactions = false; - print "

Connecting $db->databaseType...

"; - $db->Connect($connstr,$u,$p) || die("CONNECT FAILED"); - testdb($db, - "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); -} - -if (!empty($testpdoaccess)) { - $connstr = 'odbc:nwind'; - $u = '';$p=''; - $db = &ADONewConnection('pdo'); - $db->hasTransactions = false; - print "

Connecting $db->databaseType...

"; - $db->Connect($connstr,$u,$p) || die("CONNECT FAILED"); - testdb($db, - "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); -} - -if (!empty($testpdoora)) { - $connstr = 'oci:'; - $u = 'scott';$p='natsoft'; - $db = &ADONewConnection('pdo'); - #$db->hasTransactions = false; - print "

Connecting $db->databaseType...

"; - $db->Connect($connstr,$u,$p) || die("CONNECT FAILED"); - testdb($db, - "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); -} - -// REQUIRES ODBC DSN CALLED nwind -if (!empty($testaccess)) { - $db = &ADONewConnection('access'); - print "

Connecting $db->databaseType...

"; - $access = 'd:\inetpub\wwwroot\php\NWIND.MDB'; - $dsn = "nwind"; - $dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=$access;Uid=Admin;Pwd=;"; - - //$dsn = 'Provider=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=' . $access . ';'; - if ($db->PConnect($dsn, "", "", "")) - 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=;'; - $_GET['nolog'] = 1; - 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...

";flush(); - - if ( $db->PConnect("vfp-adoxyz")) { - testdb($db,"create table d:\\inetpub\\adodb\\ADOXYZ (id int, firstname char(24), lastname char(24),created date)"); - } else print "ERROR: Visual FoxPro test requires a Windows ODBC DSN=vfp-adoxyz, VFP driver"; - - echo "
"; - $db = &ADONewConnection('odbtp'); - - if ( $db->PConnect('localhost','DRIVER={Microsoft Visual FoxPro Driver};SOURCETYPE=DBF;SOURCEDB=d:\inetpub\adodb;EXCLUSIVE=NO;')) { - print "

Connecting $db->databaseType...

";flush(); - testdb($db,"create table d:\\inetpub\\adodb\\ADOXYZ (id int, firstname char(24), lastname char(24),created date)"); - } else print "ERROR: Visual FoxPro odbtp requires a Windows ODBC DSN=vfp-adoxyz, VFP driver"; - -} - - -// REQUIRES MySQL server at localhost with database 'test' -if (!empty($testmysql)) { // MYSQL - - - if (PHP_VERSION >= 5 || $_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost'; - else $server = "mangrove"; - $user = 'root'; $password = ''; $database = 'northwind'; - $db = &ADONewConnection("mysqlt://$user:$password@$server/$database?persist"); - print "

Connecting $db->databaseType...

"; - - if (true || $db->PConnect($server, "root", "", "northwind")) { - //$db->Execute("DROP TABLE ADOXYZ") || die('fail drop'); - //$db->debug=1;$db->Execute('drop table ADOXYZ'); - 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(); -} - -// REQUIRES MySQL server at localhost with database 'test' -if (!empty($testmysqli)) { // MYSQL - - $db = &ADONewConnection('mysqli'); - print "

Connecting $db->databaseType...

"; - if (PHP_VERSION >= 5 || $_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost'; - else $server = "mangrove"; - if ($db->PConnect($server, "root", "", "northwind")) { - //$db->debug=1;$db->Execute('drop table ADOXYZ'); - testdb($db, - "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); - } else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'
'.$db->ErrorMsg(); -} - - -// REQUIRES MySQL server at localhost with database 'test' -if (!empty($testmysqlodbc)) { // MYSQL - - $db = &ADONewConnection('odbc'); - $db->hasTransactions = false; - print "

Connecting $db->databaseType...

"; - if ($_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost'; - else $server = "mangrove"; - if ($db->PConnect('mysql', "root", "")) - 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(); -} - -if (!empty($testproxy)){ - $db = &ADONewConnection('proxy'); - print "

Connecting $db->databaseType...

"; - if ($_SERVER['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)) { - $dsn = "oci8po://juris10:natsoft@sherkhan?persist"; - $db = ADONewConnection($dsn); - print "

Connecting $db->databaseType...

"; - if (true || $db->Connect('', "scott", "natsoft",'')) - 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/natsoft".'
'.$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("db2"); // no longer supported -if (!empty($testdb2)) { - $db = ADONewConnection(); - print "

Connecting $db->databaseType...

"; - - $dsn = "db2_sample"; - $dsn = "driver={IBM db2 odbc DRIVER};Database=sample;hostname=localhost;port=50000;protocol=TCPIP; uid=root; pwd=natsoft"; - if ($db->Connect($dsn)) { - // testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); - } else print "ERROR: DB2 test requires an server setup with odbc data source db2_sample".'
'.$db->ErrorMsg(); - -echo "
"; -flush(); - $dsn = "driver={IBM db2 odbc DRIVER};Database=sample;hostname=localhost;port=50000;protocol=TCPIP; uid=root; pwd=natsoft"; - - $db = ADONewConnection('odbtp'); - if ($db->Connect('127.0.0.1',$dsn)) { - - $db->debug=1; - $arr = $db->GetArray( "||SQLProcedures" ); adodb_pr($arr); - $arr = $db->GetArray( "||SQLProcedureColumns|||GET_ROUTINE_SAR" );adodb_pr($arr); - - testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); - } else echo ("ERROR Connection"); - echo $db->ErrorMsg(); -} - - -$server = 'sherkhan'; - -ADOLoadCode('odbc_mssql'); -if (!empty($testmssql)) { // MS SQL Server via ODBC - $db = ADONewConnection(); - - print "

Connecting $db->databaseType...

"; - - $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=$server;Database=northwind;"; - - if ($db->PConnect($dsn, "adodb", "natsoft", "")) { - testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)"); - } - else print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN setup"; - -} - -ADOLoadCode("ado_mssql"); -if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC -- DSN-less - - $db = &ADONewConnection("ado_mssql"); - //$db->debug=1; - print "

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

"; - - $myDSN="PROVIDER=MSDASQL;DRIVER={SQL Server};" - . "SERVER=$server;DATABASE=NorthWind;UID=adodb;PWD=natsoft;Trusted_Connection=No"; - - - if ($db->PConnect($myDSN, "", "", "")) - testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)"); - else print "ERROR: MSSQL test 2 requires MS SQL 7"; - -} - - -ADOLoadCode("mssqlpo"); -if (!empty($testmssql)) { // MS SQL Server -- the extension is buggy -- probably better to use ODBC - $db = ADONewConnection("mssqlpo"); - //$db->debug=1; - print "

Connecting $db->databaseType...

"; - - $ok = $db->Connect('','adodb','natsoft','northwind'); - - if ($ok or $db->PConnect("mangrove", "sa", "natsoft", "ai")) { - AutoDetect_MSSQL_Date_Order($db); - // $db->Execute('drop table adoxyz'); - testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)"); - } else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='192.168.0.1', userid='adodb', 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...

"; - //$db->debug=1; - $myDSN="SERVER=localhost;DATABASE=northwind;Trusted_Connection=yes"; - if ($db->PConnect($myDSN, "adodb", "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'"; - -} - - -if (extension_loaded('odbtp') && !empty($testmssql)) { // MS SQL Server via ODBC - $db = ADONewConnection('odbtp'); - - $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=$server;Database=northwind;uid=adodb;pwd=natsoft"; - - if ($db->PConnect('localhost',$dsn, "", "")) { - print "

Connecting $db->databaseType...

"; - testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)"); - } - else print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN setup"; - -} - - -print "

Tests Completed

"; - -?> diff --git a/phpgwapi/inc/adodb/tests/testgenid.php b/phpgwapi/inc/adodb/tests/testgenid.php deleted file mode 100644 index bc54adac60..0000000000 --- a/phpgwapi/inc/adodb/tests/testgenid.php +++ /dev/null @@ -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 --git a/phpgwapi/inc/adodb/tests/testmssql.php b/phpgwapi/inc/adodb/tests/testmssql.php deleted file mode 100644 index 69647f4b11..0000000000 --- a/phpgwapi/inc/adodb/tests/testmssql.php +++ /dev/null @@ -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 "

"; -} -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 --git a/phpgwapi/inc/adodb/tests/testoci8.php b/phpgwapi/inc/adodb/tests/testoci8.php deleted file mode 100644 index 1c8bf28309..0000000000 --- a/phpgwapi/inc/adodb/tests/testoci8.php +++ /dev/null @@ -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 --git a/phpgwapi/inc/adodb/tests/testoci8cursor.php b/phpgwapi/inc/adodb/tests/testoci8cursor.php deleted file mode 100644 index 47ce95dfd9..0000000000 --- a/phpgwapi/inc/adodb/tests/testoci8cursor.php +++ /dev/null @@ -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 --git a/phpgwapi/inc/adodb/tests/testpaging.php b/phpgwapi/inc/adodb/tests/testpaging.php deleted file mode 100644 index 5f2aaece67..0000000000 --- a/phpgwapi/inc/adodb/tests/testpaging.php +++ /dev/null @@ -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 '
'; -$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 "
"; -} - -$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 --git a/phpgwapi/inc/adodb/tests/testpear.php b/phpgwapi/inc/adodb/tests/testpear.php deleted file mode 100644 index 05eca9c0fa..0000000000 --- a/phpgwapi/inc/adodb/tests/testpear.php +++ /dev/null @@ -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 "
"; - $cnt += 1; -} - -if ($cnt != 50) print "Error in \$cnt = $cnt"; -?> \ No newline at end of file diff --git a/phpgwapi/inc/adodb/tests/testsessions.php b/phpgwapi/inc/adodb/tests/testsessions.php deleted file mode 100644 index efc1fb4cb3..0000000000 --- a/phpgwapi/inc/adodb/tests/testsessions.php +++ /dev/null @@ -1,81 +0,0 @@ -Notify Expiring=$ref, sessionkey=$key

"; -} - -//------------------------------------------------------------------- - -error_reporting(E_ALL); - -#### CONNECTION -if (0) { - $ADODB_SESSION_DRIVER='oci8'; - $ADODB_SESSION_CONNECT=''; - $ADODB_SESSION_USER ='scott'; - $ADODB_SESSION_PWD ='natsoft'; - $ADODB_SESSION_DB =''; -} else { - $ADODB_SESSION_DRIVER='mysql'; - $ADODB_SESSION_CONNECT='localhost'; - $ADODB_SESSION_USER ='root'; - $ADODB_SESSION_PWD =''; - $ADODB_SESSION_DB ='xphplens_2'; -} - -### TURN DEBUGGING ON - $ADODB_SESS_DEBUG = 99; - - -#### SETUP NOTIFICATION - $USER = 'JLIM'.rand(); - $ADODB_SESSION_EXPIRE_NOTIFY = array('USER','NotifyExpire'); - - -#### INIT - ob_start(); - include('../session/adodb-cryptsession.php'); - session_start(); - - adodb_session_regenerate_id(); - -### SETUP SESSION VARIABLES - $_SESSION['MONKEY'] = array('1','abc',44.41); - if (!isset($_GET['nochange'])) @$_SESSION['AVAR'] += 1; - - -### START DISPLAY - print "

PHP ".PHP_VERSION."

"; - print "

\$_SESSION['AVAR']={$_SESSION['AVAR']}

"; - - print "
Cookies: "; - print_r($_COOKIE); - -### RANDOMLY PERFORM Garbage Collection -### In real-production environment, this is done for you -### by php's session extension, which calls adodb_sess_gc() -### automatically for you. See php.ini's -### session.cookie_lifetime and session.gc_probability - - if (rand() % 5 == 0) { - - print "

Garbage Collection

"; - adodb_sess_gc(10); - - if (rand() % 2 == 0) { - print "

Random session destroy

"; - session_destroy(); - } - } -?> \ No newline at end of file diff --git a/phpgwapi/inc/adodb/tests/time.php b/phpgwapi/inc/adodb/tests/time.php deleted file mode 100644 index 3bd211324d..0000000000 --- a/phpgwapi/inc/adodb/tests/time.php +++ /dev/null @@ -1,17 +0,0 @@ - - \ No newline at end of file diff --git a/phpgwapi/inc/adodb/tests/tmssql.php b/phpgwapi/inc/adodb/tests/tmssql.php deleted file mode 100644 index a3b743ca1f..0000000000 --- a/phpgwapi/inc/adodb/tests/tmssql.php +++ /dev/null @@ -1,65 +0,0 @@ -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); - -} - -function tpear() -{ -include_once('DB.php'); - - print "

PEAR

"; - $username = 'adodb'; - $password = 'natsoft'; - $hostname = 'JAGUAR\vsdotnet'; - $databasename = 'northwind'; - - $dsn = "mssql://$username:$password@$hostname/$databasename"; - $conn = &DB::connect($dsn); - print "date=".$conn->GetOne('select getdate()')."
"; - @$conn->query('create table tester (id integer)'); - print "

Delete

"; flush(); - $rs = $conn->query('delete from tester'); - print "date=".$conn->GetOne('select getdate()')."
"; -} - -function tadodb() -{ -include_once('../adodb.inc.php'); - - print "

ADOdb

"; - $conn = NewADOConnection('mssql'); - $conn->Connect('JAGUAR\vsdotnet','adodb','natsoft','northwind'); -// $conn->debug=1; - print "date=".$conn->GetOne('select getdate()')."
"; - $conn->Execute('create table tester (id integer)'); - print "

Delete

"; flush(); - $rs = $conn->Execute('delete from tester'); - print "date=".$conn->GetOne('select getdate()')."
"; -} -?> -mssql -pear -adodb - \ No newline at end of file diff --git a/phpgwapi/inc/adodb/tests/xmlschema-mssql.xml b/phpgwapi/inc/adodb/tests/xmlschema-mssql.xml deleted file mode 100644 index 2877bfc85b..0000000000 --- a/phpgwapi/inc/adodb/tests/xmlschema-mssql.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - -id - - -id - - - -
- - SQL to be executed only on specific platforms - - insert into mytable ( row1, row2 ) values ( 12, 'postgres stuff' ) - - - insert into mytable ( row1, row2 ) values ( 12, 'mysql stuff' ) - - - INSERT into simple_table ( name, description ) values ( '12', 'Microsoft stuff' ) - - -
\ No newline at end of file diff --git a/phpgwapi/inc/adodb/tests/xmlschema.xml b/phpgwapi/inc/adodb/tests/xmlschema.xml deleted file mode 100644 index 183171a414..0000000000 --- a/phpgwapi/inc/adodb/tests/xmlschema.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - An integer row that's a primary key and autoincrements - - - - - A 16 character varchar row that can't be null - - - - row1 - row2 - -
- - SQL to be executed only on specific platforms - - insert into mytable ( row1, row2 ) values ( 12, 'postgres stuff' ) - - - insert into mytable ( row1, row2 ) values ( 12, 'mysql stuff' ) - - - insert into mytable ( row1, row2 ) values ( 12, 'Microsoft stuff' ) - - - - -
-
\ No newline at end of file