Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

AdoDB tests cleanup after Secunia Advisory SA18267

  • Loading branch information...
commit 6c533543a844901d53cbd753010f9fa3cb336362 1 parent ae3c8f1
martinlanghoff authored
84 lib/adodb/tests/benchmark.php
... ... @@ -1,84 +0,0 @@
1   -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2   -
3   -<html>
4   -<head>
5   - <title>ADODB Benchmarks</title>
6   -</head>
7   -
8   -<body>
9   -<?php
10   -/*
11   -V4.66 28 Sept 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
12   - Released under both BSD license and Lesser GPL library license.
13   - Whenever there is any discrepancy between the two licenses,
14   - the BSD license will take precedence.
15   -
16   - Benchmark code to test the speed to the ADODB library with different databases.
17   - This is a simplistic benchmark to be used as the basis for further testing.
18   - It should not be used as proof of the superiority of one database over the other.
19   -*/
20   -
21   -$testmssql = true;
22   -//$testvfp = true;
23   -$testoracle = true;
24   -$testado = true;
25   -$testibase = true;
26   -$testaccess = true;
27   -$testmysql = true;
28   -$testsqlite = true;;
29   -
30   -set_time_limit(240); // increase timeout
31   -
32   -include("../tohtml.inc.php");
33   -include("../adodb.inc.php");
34   -
35   -function testdb(&$db,$createtab="create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)")
36   -{
37   -GLOBAL $ADODB_version,$ADODB_FETCH_MODE;
38   -
39   - adodb_backtrace();
40   -
41   - $max = 100;
42   - $sql = 'select * from ADOXYZ';
43   - $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
44   -
45   - //print "<h3>ADODB Version: $ADODB_version Host: <i>$db->host</i> &nbsp; Database: <i>$db->database</i></h3>";
46   -
47   - // perform query once to cache results so we are only testing throughput
48   - $rs = $db->Execute($sql);
49   - if (!$rs){
50   - print "Error in recordset<p>";
51   - return;
52   - }
53   - $arr = $rs->GetArray();
54   - //$db->debug = true;
55   - global $ADODB_COUNTRECS;
56   - $ADODB_COUNTRECS = false;
57   - $start = microtime();
58   - for ($i=0; $i < $max; $i++) {
59   - $rs =& $db->Execute($sql);
60   - $arr =& $rs->GetArray();
61   - // print $arr[0][1];
62   - }
63   - $end = microtime();
64   - $start = explode(' ',$start);
65   - $end = explode(' ',$end);
66   -
67   - //print_r($start);
68   - //print_r($end);
69   -
70   - // print_r($arr);
71   - $total = $end[0]+trim($end[1]) - $start[0]-trim($start[1]);
72   - printf ("<p>seconds = %8.2f for %d iterations each with %d records</p>",$total,$max, sizeof($arr));
73   - flush();
74   -
75   -
76   - //$db->Close();
77   -}
78   -include("testdatabases.inc.php");
79   -
80   -?>
81   -
82   -
83   -</body>
84   -</html>
194 lib/adodb/tests/client.php
... ... @@ -1,194 +0,0 @@
1   -<html>
2   -<body bgcolor=white>
3   -<?php
4   -/**
5   - * V4.50 6 July 2004 (c) 2001-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
6   - * Released under both BSD license and Lesser GPL library license.
7   - Whenever there is any discrepancy between the two licenses,
8   - the BSD license will take precedence.
9   - *
10   - * set tabs to 8
11   - */
12   -
13   - // documentation on usage is at http://php.weblogs.com/adodb_csv
14   -
15   -include('../adodb.inc.php');
16   -include('../tohtml.inc.php');
17   -
18   - function &send2server($url,$sql)
19   - {
20   - $url .= '?sql='.urlencode($sql);
21   - print "<p>$url</p>";
22   - $rs = csv2rs($url,$err);
23   - if ($err) print $err;
24   - return $rs;
25   - }
26   -
27   - function print_pre($s)
28   - {
29   - print "<pre>";print_r($s);print "</pre>";
30   - }
31   -
32   -
33   -$serverURL = 'http://localhost/php/phplens/adodb/server.php';
34   -$testhttp = false;
35   -
36   -$sql1 = "insertz into products (productname) values ('testprod 1')";
37   -$sql2 = "insert into products (productname) values ('testprod 1')";
38   -$sql3 = "insert into products (productname) values ('testprod 2')";
39   -$sql4 = "delete from products where productid>80";
40   -$sql5 = 'select * from products';
41   -
42   -if ($testhttp) {
43   - print "<a href=#c>Client Driver Tests</a><p>";
44   - print "<h3>Test Error</h3>";
45   - $rs = send2server($serverURL,$sql1);
46   - print_pre($rs);
47   - print "<hr>";
48   -
49   - print "<h3>Test Insert</h3>";
50   -
51   - $rs = send2server($serverURL,$sql2);
52   - print_pre($rs);
53   - print "<hr>";
54   -
55   - print "<h3>Test Insert2</h3>";
56   -
57   - $rs = send2server($serverURL,$sql3);
58   - print_pre($rs);
59   - print "<hr>";
60   -
61   - print "<h3>Test Delete</h3>";
62   -
63   - $rs = send2server($serverURL,$sql4);
64   - print_pre($rs);
65   - print "<hr>";
66   -
67   -
68   - print "<h3>Test Select</h3>";
69   - $rs = send2server($serverURL,$sql5);
70   - if ($rs) rs2html($rs);
71   -
72   - print "<hr>";
73   -}
74   -
75   -
76   -print "<a name=c><h1>CLIENT Driver Tests</h1>";
77   -$conn = ADONewConnection('csv');
78   -$conn->Connect($serverURL);
79   -$conn->debug = true;
80   -
81   -print "<h3>Bad SQL</h3>";
82   -
83   -$rs = $conn->Execute($sql1);
84   -
85   -print "<h3>Insert SQL 1</h3>";
86   -$rs = $conn->Execute($sql2);
87   -
88   -print "<h3>Insert SQL 2</h3>";
89   -$rs = $conn->Execute($sql3);
90   -
91   -print "<h3>Select SQL</h3>";
92   -$rs = $conn->Execute($sql5);
93   -if ($rs) rs2html($rs);
94   -
95   -print "<h3>Delete SQL</h3>";
96   -$rs = $conn->Execute($sql4);
97   -
98   -print "<h3>Select SQL</h3>";
99   -$rs = $conn->Execute($sql5);
100   -if ($rs) rs2html($rs);
101   -
102   -
103   -/* EXPECTED RESULTS FOR HTTP TEST:
104   -
105   -Test Insert
106   -http://localhost/php/adodb/server.php?sql=insert+into+products+%28productname%29+values+%28%27testprod%27%29
107   -
108   -adorecordset Object
109   -(
110   - [dataProvider] => native
111   - [fields] =>
112   - [blobSize] => 64
113   - [canSeek] =>
114   - [EOF] => 1
115   - [emptyTimeStamp] =>
116   - [emptyDate] =>
117   - [debug] =>
118   - [timeToLive] => 0
119   - [bind] =>
120   - [_numOfRows] => -1
121   - [_numOfFields] => 0
122   - [_queryID] => 1
123   - [_currentRow] => -1
124   - [_closed] =>
125   - [_inited] =>
126   - [sql] => insert into products (productname) values ('testprod')
127   - [affectedrows] => 1
128   - [insertid] => 81
129   -)
130   -
131   -
132   ---------------------------------------------------------------------------------
133   -
134   -Test Insert2
135   -http://localhost/php/adodb/server.php?sql=insert+into+products+%28productname%29+values+%28%27testprod%27%29
136   -
137   -adorecordset Object
138   -(
139   - [dataProvider] => native
140   - [fields] =>
141   - [blobSize] => 64
142   - [canSeek] =>
143   - [EOF] => 1
144   - [emptyTimeStamp] =>
145   - [emptyDate] =>
146   - [debug] =>
147   - [timeToLive] => 0
148   - [bind] =>
149   - [_numOfRows] => -1
150   - [_numOfFields] => 0
151   - [_queryID] => 1
152   - [_currentRow] => -1
153   - [_closed] =>
154   - [_inited] =>
155   - [sql] => insert into products (productname) values ('testprod')
156   - [affectedrows] => 1
157   - [insertid] => 82
158   -)
159   -
160   -
161   ---------------------------------------------------------------------------------
162   -
163   -Test Delete
164   -http://localhost/php/adodb/server.php?sql=delete+from+products+where+productid%3E80
165   -
166   -adorecordset Object
167   -(
168   - [dataProvider] => native
169   - [fields] =>
170   - [blobSize] => 64
171   - [canSeek] =>
172   - [EOF] => 1
173   - [emptyTimeStamp] =>
174   - [emptyDate] =>
175   - [debug] =>
176   - [timeToLive] => 0
177   - [bind] =>
178   - [_numOfRows] => -1
179   - [_numOfFields] => 0
180   - [_queryID] => 1
181   - [_currentRow] => -1
182   - [_closed] =>
183   - [_inited] =>
184   - [sql] => delete from products where productid>80
185   - [affectedrows] => 2
186   - [insertid] => 0
187   -)
188   -
189   -[more stuff deleted]
190   - .
191   - .
192   - .
193   -*/
194   -?>
82 lib/adodb/tests/pdo.php
... ... @@ -1,82 +0,0 @@
1   -<?php
2   -error_reporting(E_ALL);
3   -include('../adodb.inc.php');
4   -
5   -try {
6   - echo "New Connection\n";
7   - $DB = NewADOConnection('pdo');
8   - echo "Connect\n";
9   -
10   - $u = ''; $p = '';
11   - /*
12   - $connstr = 'odbc:nwind';
13   -
14   - $connstr = 'oci:';
15   - $u = 'scott';
16   - $p = 'natsoft';
17   -
18   -
19   - $connstr ="sqlite:d:\inetpub\adodb\sqlite.db";
20   - */
21   -
22   - $connstr = "mysql:dbname=northwind";
23   - $u = 'root';
24   -
25   - $connstr = "pgsql:dbname=test";
26   - $u = 'tester';
27   - $p = 'test';
28   -
29   - $DB->Connect($connstr,$u,$p) || die("CONNECT FAILED");
30   -
31   -
32   - echo "$connstr: Execute\n";
33   -
34   - //$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
35   - $rs = $DB->Execute("select * from ADOXYZ where id<3");
36   - echo "*** e=".$DB->ErrorNo() . " ".($DB->ErrorMsg())."\n";
37   -
38   -
39   - //print_r(get_class_methods($DB->_stmt));
40   -
41   - if (!$rs) die("NO RS");
42   -
43   - echo "Meta\n";
44   - for ($i=0; $i < $rs->NumCols(); $i++) {
45   - var_dump($rs->FetchField($i));
46   - echo "<br>";
47   - }
48   -
49   - echo "FETCH\n";
50   - $cnt = 0;
51   - while (!$rs->EOF) {
52   - adodb_pr($rs->fields);
53   - $rs->MoveNext();
54   - if ($cnt++ > 1000) break;
55   - }
56   -
57   - echo "<br>--------------------------------------------------------<br>\n\n\n";
58   -
59   - $stmt = $DB->PrepareStmt("select * from ADOXYZ");
60   -
61   - $rs = $stmt->Execute();
62   - $cols = $stmt->NumCols(); // execute required
63   -
64   - echo "COLS = $cols";
65   - for($i=1;$i<=$cols;$i++) {
66   - $v = $stmt->_stmt->getColumnMeta($i);
67   - var_dump($v);
68   - }
69   -
70   - echo "e=".$stmt->ErrorNo() . " ".($stmt->ErrorMsg())."\n";
71   - while ($arr = $rs->FetchRow()) {
72   - adodb_pr($arr);
73   - }
74   - die("DONE\n");
75   -
76   -} catch (exception $e) {
77   - echo "<pre>";
78   - echo $e;
79   - echo "</pre>";
80   -}
81   -
82   -?>
248 lib/adodb/tests/test-datadict.php
... ... @@ -1,248 +0,0 @@
1   -<?php
2   -/*
3   -
4   - V4.66 28 Sept 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
5   - Released under both BSD license and Lesser GPL library license.
6   - Whenever there is any discrepancy between the two licenses,
7   - the BSD license will take precedence.
8   -
9   - Set tabs to 4 for best viewing.
10   -
11   -*/
12   -
13   -error_reporting(E_ALL);
14   -include_once('../adodb.inc.php');
15   -
16   -foreach(array('sapdb','sybase','mysqlt','access','oci8','postgres','odbc_mssql','odbc','db2','firebird','informix') as $dbType) {
17   - echo "<h3>$dbType</h3><p>";
18   - $db = NewADOConnection($dbType);
19   - $dict = NewDataDictionary($db);
20   -
21   - if (!$dict) continue;
22   - $dict->debug = 1;
23   -
24   - $opts = array('REPLACE','mysql' => 'TYPE=INNODB', 'oci8' => 'TABLESPACE USERS');
25   -
26   -/* $flds = array(
27   - array('id', 'I',
28   - 'AUTO','KEY'),
29   -
30   - array('name' => 'firstname', 'type' => 'varchar','size' => 30,
31   - 'DEFAULT'=>'Joan'),
32   -
33   - array('lastname','varchar',28,
34   - 'DEFAULT'=>'Chen','key'),
35   -
36   - array('averylonglongfieldname','X',1024,
37   - 'NOTNULL','default' => 'test'),
38   -
39   - array('price','N','7.2',
40   - 'NOTNULL','default' => '0.00'),
41   -
42   - array('MYDATE', 'D',
43   - 'DEFDATE'),
44   - array('TS','T',
45   - 'DEFTIMESTAMP')
46   - );*/
47   -
48   - $flds = "
49   -ID I AUTO KEY,
50   -FIRSTNAME VARCHAR(30) DEFAULT 'Joan',
51   -LASTNAME VARCHAR(28) DEFAULT 'Chen' key,
52   -averylonglongfieldname X(1024) DEFAULT 'test',
53   -price N(7.2) DEFAULT '0.00',
54   -MYDATE D DEFDATE,
55   -BIGFELLOW X NOTNULL,
56   -TS T DEFTIMESTAMP";
57   -
58   -
59   - $sqla = $dict->CreateDatabase('KUTU',array('postgres'=>"LOCATION='/u01/postdata'"));
60   - $dict->SetSchema('KUTU');
61   -
62   - $sqli = ($dict->CreateTableSQL('testtable',$flds, $opts));
63   - $sqla = array_merge($sqla,$sqli);
64   -
65   - $sqli = $dict->CreateIndexSQL('idx','testtable','firstname,lastname',array('BITMAP','FULLTEXT','CLUSTERED','HASH'));
66   - $sqla = array_merge($sqla,$sqli);
67   - $sqli = $dict->CreateIndexSQL('idx2','testtable','price,lastname');//,array('BITMAP','FULLTEXT','CLUSTERED'));
68   - $sqla = array_merge($sqla,$sqli);
69   -
70   - $addflds = array(array('height', 'F'),array('weight','F'));
71   - $sqli = $dict->AddColumnSQL('testtable',$addflds);
72   - $sqla = array_merge($sqla,$sqli);
73   - $addflds = array(array('height', 'F','NOTNULL'),array('weight','F','NOTNULL'));
74   - $sqli = $dict->AlterColumnSQL('testtable',$addflds);
75   - $sqla = array_merge($sqla,$sqli);
76   -
77   -
78   - printsqla($dbType,$sqla);
79   -
80   - if (file_exists('d:\inetpub\wwwroot\php\phplens\adodb\adodb.inc.php'))
81   - if ($dbType == 'mysqlt') {
82   - $db->Connect('localhost', "root", "", "test");
83   - $dict->SetSchema('');
84   - $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds);
85   - if ($sqla2) printsqla($dbType,$sqla2);
86   - }
87   - if ($dbType == 'postgres') {
88   - if (@$db->Connect('localhost', "tester", "test", "test"));
89   - $dict->SetSchema('');
90   - $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds);
91   - if ($sqla2) printsqla($dbType,$sqla2);
92   - }
93   -
94   - if ($dbType == 'odbc_mssql') {
95   - $dsn = $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=localhost;Database=northwind;";
96   - if (@$db->Connect($dsn, "sa", "natsoft", "test"));
97   - $dict->SetSchema('');
98   - $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds);
99   - if ($sqla2) printsqla($dbType,$sqla2);
100   - }
101   -
102   -
103   -
104   - adodb_pr($dict->databaseType);
105   - printsqla($dbType, $dict->DropColumnSQL('table',array('my col','`col2_with_Quotes`','A_col3','col3(10)')));
106   - printsqla($dbType, $dict->ChangeTableSQL('adoxyz','LASTNAME varchar(32)'));
107   -
108   -}
109   -
110   -function printsqla($dbType,$sqla)
111   -{
112   - print "<pre>";
113   - //print_r($dict->MetaTables());
114   - foreach($sqla as $s) {
115   - $s = htmlspecialchars($s);
116   - print "$s;\n";
117   - if ($dbType == 'oci8') print "/\n";
118   - }
119   - print "</pre><hr>";
120   -}
121   -
122   -/***
123   -
124   -Generated SQL:
125   -
126   -mysql
127   -
128   -CREATE DATABASE KUTU;
129   -DROP TABLE KUTU.testtable;
130   -CREATE TABLE KUTU.testtable (
131   -id INTEGER NOT NULL AUTO_INCREMENT,
132   -firstname VARCHAR(30) DEFAULT 'Joan',
133   -lastname VARCHAR(28) NOT NULL DEFAULT 'Chen',
134   -averylonglongfieldname LONGTEXT NOT NULL,
135   -price NUMERIC(7,2) NOT NULL DEFAULT 0.00,
136   -MYDATE DATE DEFAULT CURDATE(),
137   - PRIMARY KEY (id, lastname)
138   -)TYPE=ISAM;
139   -CREATE FULLTEXT INDEX idx ON KUTU.testtable (firstname,lastname);
140   -CREATE INDEX idx2 ON KUTU.testtable (price,lastname);
141   -ALTER TABLE KUTU.testtable ADD height DOUBLE;
142   -ALTER TABLE KUTU.testtable ADD weight DOUBLE;
143   -ALTER TABLE KUTU.testtable MODIFY COLUMN height DOUBLE NOT NULL;
144   -ALTER TABLE KUTU.testtable MODIFY COLUMN weight DOUBLE NOT NULL;
145   -
146   -
147   ---------------------------------------------------------------------------------
148   -
149   -oci8
150   -
151   -CREATE USER KUTU IDENTIFIED BY tiger;
152   -/
153   -GRANT CREATE SESSION, CREATE TABLE,UNLIMITED TABLESPACE,CREATE SEQUENCE TO KUTU;
154   -/
155   -DROP TABLE KUTU.testtable CASCADE CONSTRAINTS;
156   -/
157   -CREATE TABLE KUTU.testtable (
158   -id NUMBER(16) NOT NULL,
159   -firstname VARCHAR(30) DEFAULT 'Joan',
160   -lastname VARCHAR(28) DEFAULT 'Chen' NOT NULL,
161   -averylonglongfieldname CLOB NOT NULL,
162   -price NUMBER(7,2) DEFAULT 0.00 NOT NULL,
163   -MYDATE DATE DEFAULT TRUNC(SYSDATE),
164   - PRIMARY KEY (id, lastname)
165   -)TABLESPACE USERS;
166   -/
167   -DROP SEQUENCE KUTU.SEQ_testtable;
168   -/
169   -CREATE SEQUENCE KUTU.SEQ_testtable;
170   -/
171   -CREATE OR REPLACE TRIGGER KUTU.TRIG_SEQ_testtable BEFORE insert ON KUTU.testtable
172   - FOR EACH ROW
173   - BEGIN
174   - select KUTU.SEQ_testtable.nextval into :new.id from dual;
175   - END;
176   -/
177   -CREATE BITMAP INDEX idx ON KUTU.testtable (firstname,lastname);
178   -/
179   -CREATE INDEX idx2 ON KUTU.testtable (price,lastname);
180   -/
181   -ALTER TABLE testtable ADD (
182   - height NUMBER,
183   - weight NUMBER);
184   -/
185   -ALTER TABLE testtable MODIFY(
186   - height NUMBER NOT NULL,
187   - weight NUMBER NOT NULL);
188   -/
189   -
190   -
191   ---------------------------------------------------------------------------------
192   -
193   -postgres
194   -AlterColumnSQL not supported for PostgreSQL
195   -
196   -
197   -CREATE DATABASE KUTU LOCATION='/u01/postdata';
198   -DROP TABLE KUTU.testtable;
199   -CREATE TABLE KUTU.testtable (
200   -id SERIAL,
201   -firstname VARCHAR(30) DEFAULT 'Joan',
202   -lastname VARCHAR(28) DEFAULT 'Chen' NOT NULL,
203   -averylonglongfieldname TEXT NOT NULL,
204   -price NUMERIC(7,2) DEFAULT 0.00 NOT NULL,
205   -MYDATE DATE DEFAULT CURRENT_DATE,
206   - PRIMARY KEY (id, lastname)
207   -);
208   -CREATE INDEX idx ON KUTU.testtable USING HASH (firstname,lastname);
209   -CREATE INDEX idx2 ON KUTU.testtable (price,lastname);
210   -ALTER TABLE KUTU.testtable ADD height FLOAT8;
211   -ALTER TABLE KUTU.testtable ADD weight FLOAT8;
212   -
213   -
214   ---------------------------------------------------------------------------------
215   -
216   -odbc_mssql
217   -
218   -CREATE DATABASE KUTU;
219   -DROP TABLE KUTU.testtable;
220   -CREATE TABLE KUTU.testtable (
221   -id INT IDENTITY(1,1) NOT NULL,
222   -firstname VARCHAR(30) DEFAULT 'Joan',
223   -lastname VARCHAR(28) DEFAULT 'Chen' NOT NULL,
224   -averylonglongfieldname TEXT NOT NULL,
225   -price NUMERIC(7,2) DEFAULT 0.00 NOT NULL,
226   -MYDATE DATETIME DEFAULT GetDate(),
227   - PRIMARY KEY (id, lastname)
228   -);
229   -CREATE CLUSTERED INDEX idx ON KUTU.testtable (firstname,lastname);
230   -CREATE INDEX idx2 ON KUTU.testtable (price,lastname);
231   -ALTER TABLE KUTU.testtable ADD
232   - height REAL,
233   - weight REAL;
234   -ALTER TABLE KUTU.testtable ALTER COLUMN height REAL NOT NULL;
235   -ALTER TABLE KUTU.testtable ALTER COLUMN weight REAL NOT NULL;
236   -
237   -
238   ---------------------------------------------------------------------------------
239   -*/
240   -
241   -
242   -echo "<h1>Test XML Schema</h1>";
243   -$ff = file('xmlschema.xml');
244   -echo "<pre>";
245   -foreach($ff as $xml) echo htmlspecialchars($xml);
246   -echo "</pre>";
247   -include_once('test-xmlschema.php');
248   -?>
50 lib/adodb/tests/test-perf.php
... ... @@ -1,50 +0,0 @@
1   -<?php
2   -
3   -include_once('../adodb-perf.inc.php');
4   -
5   -error_reporting(E_ALL);
6   -session_start();
7   -
8   -if (isset($_GET)) {
9   - foreach($_GET as $k => $v) {
10   - if (strncmp($k,'test',4) == 0) $_SESSION['_db'] = $k;
11   - }
12   -}
13   -
14   -if (isset($_SESSION['_db'])) {
15   - $_db = $_SESSION['_db'];
16   - $_GET[$_db] = 1;
17   - $$_db = 1;
18   -}
19   -
20   -echo "<h1>Performance Monitoring</h1>";
21   -include_once('testdatabases.inc.php');
22   -
23   -
24   -function testdb($db)
25   -{
26   - if (!$db) return;
27   - echo "<font size=1>";print_r($db->ServerInfo()); echo " user=".$db->user."</font>";
28   -
29   - $perf = NewPerfMonitor($db);
30   -
31   - # unit tests
32   - if (0) {
33   - //$DB->debug=1;
34   - echo "Data Cache Size=".$perf->DBParameter('data cache size').'<p>';
35   - echo $perf->HealthCheck();
36   - echo($perf->SuspiciousSQL());
37   - echo($perf->ExpensiveSQL());
38   - echo($perf->InvalidSQL());
39   - echo $perf->Tables();
40   -
41   - echo "<pre>";
42   - echo $perf->HealthCheckCLI();
43   - $perf->Poll(3);
44   - die();
45   - }
46   -
47   - if ($perf) $perf->UI(3);
48   -}
49   -
50   -?>
88 lib/adodb/tests/test-pgblob.php
... ... @@ -1,88 +0,0 @@
1   -<?php
2   -
3   -function getmicrotime()
4   -{
5   - $t = microtime();
6   - $t = explode(' ',$t);
7   - return (float)$t[1]+ (float)$t[0];
8   -}
9   -
10   -function doloop()
11   -{
12   -global $db,$MAX;
13   -
14   - $sql = "select id,firstname,lastname from adoxyz where
15   - firstname not like ? and lastname not like ? and id=?";
16   - $offset = 0;
17   - /*$sql = "select * from juris9.employee join juris9.emp_perf_plan on epp_empkey = emp_id
18   - where emp_name not like ? and emp_name not like ? and emp_id=28000+?";
19   - $offset = 28000;*/
20   - for ($i=1; $i <= $MAX; $i++) {
21   - $db->Param(false);
22   - $x = (rand() % 10) + 1;
23   - $db->debug= ($i==1);
24   - $id = $db->GetOne($sql,
25   - array('Z%','Z%',$x));
26   - if($id != $offset+$x) {
27   - print "<p>Error at $x";
28   - break;
29   - }
30   - }
31   -}
32   -
33   -include_once('../adodb.inc.php');
34   -$db = NewADOConnection('postgres7');
35   -$db->PConnect('localhost','tester','test','test') || die("failed connection");
36   -
37   -$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";
38   -$val = rawurldecode($enc);
39   -
40   -$MAX = 1000;
41   -
42   -adodb_pr($db->ServerInfo());
43   -
44   -echo "<h4>Testing PREPARE/EXECUTE PLAN</h4>";
45   -
46   -
47   -$db->_bindInputArray = true; // requires postgresql 7.3+ and ability to modify database
48   -$t = getmicrotime();
49   -doloop();
50   -echo '<p>',$MAX,' times, with plan=',getmicrotime() - $t,'</p>';
51   -
52   -
53   -$db->_bindInputArray = false;
54   -$t = getmicrotime();
55   -doloop();
56   -echo '<p>',$MAX,' times, no plan=',getmicrotime() - $t,'</p>';
57   -
58   -
59   -
60   -echo "<h4>Testing UPDATEBLOB</h4>";
61   -$db->debug=1;
62   -
63   -### TEST BEGINS
64   -
65   -$db->Execute("insert into photos (id,name) values(9999,'dot.gif')");
66   -$db->UpdateBlob('photos','photo',$val,'id=9999');
67   -$v = $db->GetOne('select photo from photos where id=9999');
68   -
69   -
70   -### CLEANUP
71   -
72   -$db->Execute("delete from photos where id=9999");
73   -
74   -### VALIDATION
75   -
76   -if ($v !== $val) echo "<b>*** ERROR: Inserted value does not match downloaded val<b>";
77   -else echo "<b>*** OK: Passed</b>";
78   -
79   -echo "<pre>";
80   -echo "INSERTED: ", $enc;
81   -echo "<hr>";
82   -echo"RETURNED: ", rawurlencode($v);
83   -echo "<hr><p>";
84   -echo "INSERTED: ", $val;
85   -echo "<hr>";
86   -echo "RETURNED: ", $v;
87   -
88   -?>
78 lib/adodb/tests/test-php5.php
... ... @@ -1,78 +0,0 @@
1   -<?php
2   -/*
3   - V4.66 28 Sept 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
4   - Released under both BSD license and Lesser GPL library license.
5   - Whenever there is any discrepancy between the two licenses,
6   - the BSD license will take precedence.
7   - Set tabs to 8.
8   - */
9   -
10   -
11   -error_reporting(E_ALL);
12   -
13   -$path = dirname(__FILE__);
14   -
15   -include("$path/../adodb-exceptions.inc.php");
16   -include("$path/../adodb.inc.php");
17   -
18   -echo "<h3>PHP ".PHP_VERSION."</h3>\n";
19   -try {
20   -
21   -$dbt = 'mysql';
22   -
23   -try {
24   -switch($dbt) {
25   -case 'oci8po':
26   - $db = NewADOConnection("oci8po");
27   -
28   - $db->Connect('','scott','natsoft');
29   - break;
30   -default:
31   -case 'mysql':
32   - $db = NewADOConnection("mysql");
33   - $db->Connect('localhost','roots','','northwind');
34   - break;
35   -
36   -case 'mysqli':
37   - $db = NewADOConnection("mysqli://root:@localhost/northwind");
38   - //$db->Connect('localhost','root','','test');
39   - break;
40   -}
41   -} catch (exception $e){
42   - echo "Connect Failed";
43   - adodb_pr($e);
44   - die();
45   -}
46   -
47   -$db->debug=1;
48   -
49   -$cnt = $db->GetOne("select count(*) from adoxyz where ?<id and id<?",array(10,20));
50   -$stmt = $db->Prepare("select * from adoxyz where ?<id and id<?");
51   -if (!$stmt) echo $db->ErrorMsg(),"\n";
52   -$rs = $db->Execute($stmt,array(10,20));
53   -
54   -echo "<hr> Foreach Iterator Test (rand=".rand().")<hr>";
55   -$i = 0;
56   -foreach($rs as $v) {
57   - $i += 1;
58   - echo "rec $i: "; $s1 = adodb_pr($v,true); $s2 = adodb_pr($rs->fields,true);
59   - if ($s1 != $s2 && !empty($v)) {adodb_pr($s1); adodb_pr($s2);}
60   - else echo "passed<br>";
61   - flush();
62   -}
63   -
64   -
65   -if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n");
66   -else echo "Count $i is correct<br>";
67   -
68   -$rs = $db->Execute("select bad from badder");
69   -
70   -} catch (exception $e) {
71   - adodb_pr($e);
72   - echo "<h3>adodb_backtrace:</h3>\n";
73   - $e = adodb_backtrace($e->gettrace());
74   -}
75   -
76   -$rs = $db->Execute("select distinct id, firstname,lastname from adoxyz order by id");
77   -echo "Result=\n",$rs;
78   -?>
54 lib/adodb/tests/test-xmlschema.php
... ... @@ -1,54 +0,0 @@
1   -<?PHP
2   -
3   -// V4.50 6 July 2004
4   -
5   -error_reporting(E_ALL);
6   -include_once( "../adodb.inc.php" );
7   -include_once( "../adodb-xmlschema.inc.php" );
8   -
9   -// To build the schema, start by creating a normal ADOdb connection:
10   -$db = ADONewConnection( 'mysql' );
11   -$db->Connect( 'localhost', 'root', '', 'schematest' );
12   -
13   -// To create a schema object and build the query array.
14   -$schema = new adoSchema( $db );
15   -
16   -// To upgrade an existing schema object, use the following
17   -// To upgrade an existing database to the provided schema,
18   -// uncomment the following line:
19   -#$schema->upgradeSchema();
20   -
21   -print "<b>SQL to build xmlschema.xml</b>:\n<pre>";
22   -// Build the SQL array
23   -$sql = $schema->ParseSchema( "xmlschema.xml" );
24   -
25   -print_r( $sql );
26   -print "</pre>\n";
27   -
28   -// Execute the SQL on the database
29   -//$result = $schema->ExecuteSchema( $sql );
30   -
31   -// Finally, clean up after the XML parser
32   -// (PHP won't do this for you!)
33   -//$schema->Destroy();
34   -
35   -
36   -
37   -print "<b>SQL to build xmlschema-mssql.xml</b>:\n<pre>";
38   -
39   -$db2 = ADONewConnection('mssql');
40   -$db2->Connect('','adodb','natsoft','northwind') || die("Fail 2");
41   -
42   -$db2->Execute("drop table simple_table");
43   -
44   -$schema = new adoSchema( $db2 );
45   -$sql = $schema->ParseSchema( "xmlschema-mssql.xml" );
46   -
47   -print_r( $sql );
48   -print "</pre>\n";
49   -
50   -$db2->debug=1;
51   -
52   -foreach ($sql as $s)
53   -$db2->Execute($s);
54   -?>
1,705 lib/adodb/tests/test.php
... ... @@ -1,1705 +0,0 @@
1   -<?php
2   -/*
3   -V4.66 28 Sept 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
4   - Released under both BSD license and Lesser GPL library license.
5   - Whenever there is any discrepancy between the two licenses,
6   - the BSD license will take precedence.
7   - Set tabs to 4 for best viewing.
8   -
9   - Latest version is available at http://adodb.sourceforge.net
10   -*/
11   -
12   -error_reporting(E_ALL);
13   -
14   -$ADODB_FLUSH = true;
15   -
16   -define('ADODB_ASSOC_CASE',0);
17   -
18   -
19   -function getmicrotime()
20   -{
21   - $t = microtime();
22   - $t = explode(' ',$t);
23   - return (float)$t[1]+ (float)$t[0];
24   -}
25   -
26   -
27   -if (PHP_VERSION < 5) include_once('../adodb-pear.inc.php');
28   -//--------------------------------------------------------------------------------------
29   -//define('ADODB_ASSOC_CASE',1);
30   -//
31   -function Err($msg)
32   -{
33   - print "<b>$msg</b><br>";
34   - flush();
35   -}
36   -
37   -function CheckWS($conn)
38   -{
39   -global $ADODB_EXTENSION;
40   -
41   - include_once('../session/adodb-session.php');
42   - if (defined('CHECKWSFAIL')){ echo " TESTING $conn ";flush();}
43   - $saved = $ADODB_EXTENSION;
44   - $db = ADONewConnection($conn);
45   - $ADODB_EXTENSION = $saved;
46   - if (headers_sent()) {
47   - print "<p><b>White space detected in adodb-$conn.inc.php or include file...</b></p>";
48   - //die();
49   - }
50   -}
51   -
52   -function do_strtolower(&$arr)
53   -{
54   - foreach($arr as $k => $v) {
55   - if (is_object($v)) $arr[$k] = adodb_pr($v,true);
56   - else $arr[$k] = strtolower($v);
57   - }
58   -}
59   -
60   -
61   -function CountExecs($db, $sql, $inputarray)
62   -{
63   -global $EXECS; $EXECS++;
64   -}
65   -
66   -function CountCachedExecs($db, $secs2cache, $sql, $inputarray)
67   -{
68   -global $CACHED; $CACHED++;
69   -}
70   -
71   -// the table creation code is specific to the database, so we allow the user
72   -// to define their own table creation stuff
73   -
74   -function testdb(&$db,$createtab="create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)")
75   -{
76   -GLOBAL $ADODB_vers,$ADODB_CACHE_DIR,$ADODB_FETCH_MODE,$ADODB_COUNTRECS;
77   -
78   -?> <form method=GET>
79   - </p>
80   - <table width=100% ><tr><td bgcolor=beige>&nbsp;</td></tr></table>
81   - </p>
82   -<?php
83   - $create =false;
84   - /*$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
85   -
86   - $rs = $db->Execute('select lastname,firstname,lastname,id from adoxyz');
87   - $arr = $rs->GetAssoc();
88   - echo "<pre>";print_r($arr);
89   - die();*/
90   -
91   - GLOBAL $EXECS, $CACHED;
92   -
93   - $EXECS = 0;
94   - $CACHED = 0;
95   - //$db->Execute("drop table adodb_logsql");
96   - if ((rand()%3) == 0) @$db->Execute("delete from adodb_logsql");
97   - $db->debug=1;
98   -
99   - $db->fnExecute = 'CountExecs';
100   - $db->fnCacheExecute = 'CountCachedExecs';
101   -
102   - if (empty($_GET['nolog'])) {
103   - echo "<h3>SQL Logging enabled</h3>";
104   - $db->LogSQL();/*
105   - $sql =
106   -"SELECT t1.sid, t1.sid, t1.title, t1.hometext, t1.notes, t1.aid, t1.informant,
107   -t2.url, t2.email, t1.catid, t3.title, t1.topic, t4.topicname, t4.topicimage,
108   -t4.topictext, t1.score, t1.ratings, t1.counter, t1.comments, t1.acomm
109   -FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_topics` `t4`
110   - WHERE ((t2.aid=t1.aid) AND (t3.catid=t1.catid) AND (t4.topicid=t1.topic)
111   - AND ((t1.alanguage='german') OR (t1.alanguage='')) AND (t1.ihome='0'))
112   - ORDER BY t1.time DESC";
113   - $db->SelectLimit($sql);
114   - echo $db->ErrorMsg();*/
115   - }
116   - $ADODB_CACHE_DIR = dirname(TempNam('/tmp','testadodb'));
117   - $db->debug = false;
118   - //print $db->UnixTimeStamp('2003-7-22 23:00:00');
119   -
120   - $phpv = phpversion();
121   - if (defined('ADODB_EXTENSION')) $ext = ' &nbsp; Extension '.ADODB_EXTENSION.' installed';
122   - else $ext = '';
123   - print "<h3>ADODB Version: $ADODB_vers Host: <i>$db->host</i> &nbsp; Database: <i>$db->database</i> &nbsp; PHP: $phpv $ext</h3>";
124   - flush();
125   -
126   -
127   - $arr = $db->ServerInfo();
128   - print_r($arr);
129   - echo "<br>";
130   - $e = error_reporting(E_ALL-E_WARNING);
131   - flush();
132   -
133   - $tt = $db->Time();
134   - if ($tt == 0) echo '<br><b>$db->Time failed</b>';
135   - else echo "<br>db->Time: ".date('d-m-Y H:i:s',$tt);
136   - echo '<br>';
137   -
138   - echo "Date=",$db->UserDate('2002-04-07'),'<br>';
139   - print "<i>date1</i> (1969-02-20) = ".$db->DBDate('1969-2-20');
140   - print "<br><i>date1</i> (1999-02-20) = ".$db->DBDate('1999-2-20');
141   - print "<br><i>date1.1</i> 1999 = ".$db->DBDate("'1999'");
142   - print "<br><i>date2</i> (1970-1-2) = ".$db->DBDate(24*3600)."<p>";
143   - print "<i>ts1</i> (1999-02-20 13:40:50) = ".$db->DBTimeStamp('1999-2-20 1:40:50 pm');
144   - print "<br><i>ts1.1</i> (1999-02-20 13:40:00) = ".$db->DBTimeStamp('1999-2-20 13:40');
145   - print "<br><i>ts2</i> (1999-02-20) = ".$db->DBTimeStamp('1999-2-20');
146   - print "<br><i>ts3</i> (1970-1-2 +/- timezone) = ".$db->DBTimeStamp(24*3600);
147   - print "<br> Fractional TS (1999-2-20 13:40:50.91): ".$db->DBTimeStamp($db->UnixTimeStamp('1999-2-20 13:40:50.91+1'));
148   - $dd = $db->UnixDate('1999-02-20');
149   - print "<br>unixdate</i> 1999-02-20 = ".date('Y-m-d',$dd)."<p>";
150   - print "<br><i>ts4</i> =".($db->UnixTimeStamp("19700101000101")+8*3600);
151   - print "<br><i>ts5</i> =".$db->DBTimeStamp($db->UnixTimeStamp("20040110092123"));
152   - print "<br><i>ts6</i> =".$db->UserTimeStamp("20040110092123");
153   - print "<br><i>ts7</i> =".$db->DBTimeStamp("20040110092123");
154   - flush();
155   - // mssql too slow in failing bad connection
156   - if (false && $db->databaseType != 'mssql') {
157   - print "<p>Testing bad connection. Ignore following error msgs:<br>";
158   - $db2 = ADONewConnection();
159   - $rez = $db2->Connect("bad connection");
160   - $err = $db2->ErrorMsg();
161   - print "<i>Error='$err'</i></p>";
162   - if ($rez) print "<b>Cannot check if connection failed.</b> The Connect() function returned true.</p>";
163   - }
164   - error_reporting($e);
165   - flush();
166   -
167   - //$ADODB_COUNTRECS=false;
168   - $rs=$db->Execute('select * from adoxyz order by id');
169   - if($rs === false) $create = true;
170   - else $rs->Close();
171   -
172   - //if ($db->databaseType !='vfp') $db->Execute("drop table ADOXYZ");
173   -
174   - if ($create) {
175   - if (false && $db->databaseType == 'ibase') {
176   - print "<b>Please create the following table for testing:</b></p>$createtab</p>";
177   - return;
178   - } else {
179   - $db->debug = 99;
180   - $e = error_reporting(E_ALL-E_WARNING);
181   - $db->Execute($createtab);
182   - error_reporting($e);
183   - }
184   - }
185   -
186   - echo "<p>Testing Metatypes</p>";
187   - $t = $db->MetaType('varchar');
188   - if ($t != 'C') Err("Bad Metatype for varchar");
189   -
190   - $rs = &$db->Execute("delete from ADOXYZ"); // some ODBC drivers will fail the drop so we delete
191   - if ($rs) {
192   - if(! $rs->EOF) print "<b>Error: </b>RecordSet returned by Execute('delete...') should show EOF</p>";
193   - $rs->Close();
194   - } else print "err=".$db->ErrorMsg();
195   -
196   - print "<p>Test select on empty table, FetchField when EOF, and GetInsertSQL</p>";
197   - $rs = &$db->Execute("select id,firstname from ADOXYZ where id=9999");
198   - if ($rs && !$rs->EOF) print "<b>Error: </b>RecordSet returned by Execute(select...') on empty table should show EOF</p>";
199   - if ($rs->EOF && (($ox = $rs->FetchField(0)) && !empty($ox->name))) {
200   - $record['id'] = 99;
201   - $record['firstname'] = 'John';
202   - $sql = $db->GetInsertSQL($rs, $record);
203   - if (strtoupper($sql) != strtoupper("INSERT INTO ADOXYZ ( id, firstname ) VALUES ( 99, 'John' )")) Err("GetInsertSQL does not work on empty table: $sql");
204   - } else {
205   - Err("FetchField does not work on empty recordset, meaning GetInsertSQL will fail...");
206   - }
207   - if ($rs) $rs->Close();
208   - flush();
209   - //$db->debug=true;
210   - print "<p>Testing Commit: ";
211   - $time = $db->DBDate(time());
212   - if (!$db->BeginTrans()) {
213   - print '<b>Transactions not supported</b></p>';
214   - if ($db->hasTransactions) Err("hasTransactions should be false");
215   - } else { /* COMMIT */
216   - if (!$db->hasTransactions) Err("hasTransactions should be true");
217   - if ($db->transCnt != 1) Err("Invalid transCnt = $db->transCnt (should be 1)");
218   - $rs = $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values (99,'Should Not','Exist (Commit)',$time)");
219   - if ($rs && $db->CommitTrans()) {
220   - $rs->Close();
221   - $rs = &$db->Execute("select * from ADOXYZ where id=99");
222   - if ($rs === false || $rs->EOF) {
223   - print '<b>Data not saved</b></p>';
224   - $rs = &$db->Execute("select * from ADOXYZ where id=99");
225   - print_r($rs);
226   - die();
227   - } else print 'OK</p>';
228   - if ($rs) $rs->Close();
229   - } else {
230   - if (!$rs) {
231   - print "<b>Insert failed</b></p>";
232   - $db->RollbackTrans();
233   - } else print "<b>Commit failed</b></p>";
234   - }
235   - if ($db->transCnt != 0) Err("Invalid transCnt = $db->transCnt (should be 0)");
236   -
237   - /* ROLLBACK */
238   - if (!$db->BeginTrans()) print "<p><b>Error in BeginTrans</b>()</p>";
239   - print "<p>Testing Rollback: ";
240   - $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values (100,'Should Not','Exist (Rollback)',$time)");
241   - if ($db->RollbackTrans()) {
242   - $rs = $db->Execute("select * from ADOXYZ where id=100");
243   - if ($rs && !$rs->EOF) print '<b>Fail: Data should rollback</b></p>';
244   - else print 'OK</p>';
245   - if ($rs) $rs->Close();
246   - } else
247   - print "<b>Commit failed</b></p>";
248   -
249   - $rs = &$db->Execute('delete from ADOXYZ where id>50');
250   - if ($rs) $rs->Close();
251   -
252   - if ($db->transCnt != 0) Err("Invalid transCnt = $db->transCnt (should be 0)");
253   - }
254   -
255   - if (1) {
256   - print "<p>Testing MetaDatabases()</p>";
257   - print_r( $db->MetaDatabases());
258   -
259   - print "<p>Testing MetaTables() and MetaColumns()</p>";
260   - $a = $db->MetaTables();
261   - if ($a===false) print "<b>MetaTables not supported</b></p>";
262   - else {
263   - print "Array of tables and views: ";
264   - foreach($a as $v) print " ($v) ";
265   - print '</p>';
266   - }
267   -
268   - $a = $db->MetaTables('VIEW');
269   - if ($a===false) print "<b>MetaTables not supported (views)</b></p>";
270   - else {
271   - print "Array of views: ";
272   - foreach($a as $v) print " ($v) ";
273   - print '</p>';
274   - }
275   -
276   - $a = $db->MetaTables(false,false,'aDo%');
277   - if ($a===false) print "<b>MetaTables not supported (mask)</b></p>";
278   - else {
279   - print "Array of ado%: ";
280   - foreach($a as $v) print " ($v) ";
281   - print '</p>';
282   - }
283   -
284   - $a = $db->MetaTables('TABLE');
285   - if ($a===false) print "<b>MetaTables not supported</b></p>";
286   - else {
287   - print "Array of tables: ";
288   - foreach($a as $v) print " ($v) ";
289