Changeset 34 for trunk/phpgwapi/inc/adodb/tests/testdatabases.inc.php
- Timestamp:
- 06/29/07 15:17:46 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpgwapi/inc/adodb/tests/testdatabases.inc.php
r2 r34 2 2 3 3 /* 4 V4. 51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.4 V4.80 8 Mar 2006 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. 5 5 Released under both BSD license and Lesser GPL library license. 6 6 Whenever there is any discrepancy between the two licenses, … … 18 18 <input type=checkbox name="testmysql" value=1 <?php echo !empty($testmysql) ? 'checked' : '' ?>> <b>MySQL</b><br> 19 19 <input type=checkbox name="testmysqlodbc" value=1 <?php echo !empty($testmysqlodbc) ? 'checked' : '' ?>> <b>MySQL ODBC</b><br> 20 <input type=checkbox name="testmysqli" value=1 <?php echo !empty($testmysqli) ? 'checked' : '' ?>> <b>MySQLi</b> 21 <br> 20 22 <td><input type=checkbox name="testsqlite" value=1 <?php echo !empty($testsqlite) ? 'checked' : '' ?>> <b>SQLite</b><br> 21 23 <input type=checkbox name="testproxy" value=1 <?php echo !empty($testproxy) ? 'checked' : '' ?>> <b>MySQL Proxy</b><br> … … 23 25 <input type=checkbox name="testpostgres" value=1 <?php echo !empty($testpostgres) ? 'checked' : '' ?>> <b>PostgreSQL</b><br> 24 26 <input type=checkbox name="testpgodbc" value=1 <?php echo !empty($testpgodbc) ? 'checked' : '' ?>> <b>PostgreSQL ODBC</b><br> 27 <td> 28 <input type=checkbox name="testpdopgsql" value=1 <?php echo !empty($testpdopgsql) ? 'checked' : '' ?>> <b>PgSQL PDO</b><br> 29 <input type=checkbox name="testpdomysql" value=1 <?php echo !empty($testpdomysql) ? 'checked' : '' ?>> <b>MySQL PDO</b><br> 30 <input type=checkbox name="testpdosqlite" value=1 <?php echo !empty($testpdosqlite) ? 'checked' : '' ?>> <b>SQLite PDO</b><br> 31 <input type=checkbox name="testpdoaccess" value=1 <?php echo !empty($testpdoaccess) ? 'checked' : '' ?>> <b>Access PDO</b><br> 32 <input type=checkbox name="testpdomssql" value=1 <?php echo !empty($testpdomssql) ? 'checked' : '' ?>> <b>MSSQL PDO</b><br> 33 34 <input type=checkbox name="testpdoora" value=1 <?php echo !empty($testpdoora) ? 'checked' : '' ?>> <b>OCI PDO</b><br> 35 25 36 <td><input type=checkbox name="testdb2" value=1 <?php echo !empty($testdb2) ? 'checked' : '' ?>> DB2<br> 26 <input type=checkbox name="testvfp" value=1 <?php echo !empty($testvfp) ? 'checked' : '' ?>> VFP <br>37 <input type=checkbox name="testvfp" value=1 <?php echo !empty($testvfp) ? 'checked' : '' ?>> VFP+ODBTP<br> 27 38 <input type=checkbox name="testado" value=1 <?php echo !empty($testado) ? 'checked' : '' ?>> ADO (for mssql and access)<br> 28 39 <input type=checkbox name="nocountrecs" value=1 <?php echo !empty($nocountrecs) ? 'checked' : '' ?>> $ADODB_COUNTRECS=false<br> 29 40 <input type=checkbox name="nolog" value=1 <?php echo !empty($nolog) ? 'checked' : '' ?>> No SQL Logging<br> 30 <td><input type=submit> 41 <input type=checkbox name="time" value=1 <?php echo !empty($_GET['time']) ? 'checked' : '' ?>> ADOdb time test 42 </table> 43 <input type=submit> 31 44 </form> 32 </table> 45 33 46 <?php 34 47 … … 42 55 if (!strpos(PHP_VERSION,'5') === 0) { 43 56 ADOLoadCode("sybase"); 44 ADOLoadCode("postgres");45 ADOLoadCode("postgres7");57 //ADOLoadCode("postgres"); 58 //ADOLoadCode("postgres7"); 46 59 ADOLoadCode("firebird"); 47 60 ADOLoadCode("borland_ibase"); … … 81 94 $db = &ADONewConnection('firebird'); 82 95 print "<h1>Connecting $db->databaseType...</h1>"; 83 if ($db->PConnect("localhost:d:\\firebird\\1 0\\examples\\employee.gdb", "sysdba", "masterkey", ""))96 if ($db->PConnect("localhost:d:\\firebird\\151\\examples\\EMPLOYEE.fdb", "sysdba", "masterkey", "")) 84 97 testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname char(24),price numeric(12,2),created date)"); 85 98 else print "ERROR: Interbase test requires a database called employee.gdb".'<BR>'.$db->ErrorMsg(); … … 89 102 90 103 if (!empty($testsqlite)) { 91 $db = &ADONewConnection('sqlite'); 92 print "<h1>Connecting $db->databaseType...</h1>"; 93 94 if ($db->PConnect("d:\\inetpub\\adodb\\sqlite.db", "", "", "")) 104 $path =urlencode('d:\inetpub\adodb\sqlite.db'); 105 $dsn = "sqlite://$path/"; 106 $db = ADONewConnection($dsn); 107 //echo $dsn; 108 109 //$db = &ADONewConnection('sqlite'); 110 111 112 if ($db && $db->PConnect("d:\\inetpub\\adodb\\sqlite.db", "", "", "")) { 113 print "<h1>Connecting $db->databaseType...</h1>"; 95 114 testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)"); 96 else print "ERROR: SQLite"; 97 115 } else 116 print "ERROR: SQLite"; 117 118 } 119 120 if (!empty($testpdopgsql)) { 121 $connstr = "pgsql:dbname=test"; 122 $u = 'tester';$p='test'; 123 $db = &ADONewConnection('pdo'); 124 print "<h1>Connecting $db->databaseType...</h1>"; 125 $db->Connect($connstr,$u,$p) || die("CONNECT FAILED"); 126 testdb($db, 127 "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); 128 } 129 130 if (!empty($testpdomysql)) { 131 $connstr = "mysql:dbname=northwind"; 132 $u = 'root';$p=''; 133 $db = &ADONewConnection('pdo'); 134 print "<h1>Connecting $db->databaseType...</h1>"; 135 $db->Connect($connstr,$u,$p) || die("CONNECT FAILED"); 136 137 testdb($db, 138 "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); 139 } 140 141 if (!empty($testpdomssql)) { 142 $connstr = "mssql:dbname=northwind"; 143 $u = 'sa';$p='natsoft'; 144 $db = &ADONewConnection('pdo'); 145 print "<h1>Connecting $db->databaseType...</h1>"; 146 $db->Connect($connstr,$u,$p) || die("CONNECT FAILED"); 147 148 testdb($db, 149 "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); 150 } 151 152 if (!empty($testpdosqlite)) { 153 $connstr = "sqlite:d:/inetpub/adodb/sqlite-pdo.db3"; 154 $u = '';$p=''; 155 $db = &ADONewConnection('pdo'); 156 $db->hasTransactions = false; 157 print "<h1>Connecting $db->databaseType...</h1>"; 158 $db->Connect($connstr,$u,$p) || die("CONNECT FAILED"); 159 testdb($db, 160 "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); 161 } 162 163 if (!empty($testpdoaccess)) { 164 $connstr = 'odbc:nwind'; 165 $u = '';$p=''; 166 $db = &ADONewConnection('pdo'); 167 $db->hasTransactions = false; 168 print "<h1>Connecting $db->databaseType...</h1>"; 169 $db->Connect($connstr,$u,$p) || die("CONNECT FAILED"); 170 testdb($db, 171 "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); 172 } 173 174 if (!empty($testpdoora)) { 175 $connstr = 'oci:'; 176 $u = 'scott';$p='natsoft'; 177 $db = &ADONewConnection('pdo'); 178 #$db->hasTransactions = false; 179 print "<h1>Connecting $db->databaseType...</h1>"; 180 $db->Connect($connstr,$u,$p) || die("CONNECT FAILED"); 181 testdb($db, 182 "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); 98 183 } 99 184 … … 122 207 . 'DATA SOURCE=' . $access . ';'; 123 208 //. 'USER ID=;PASSWORD=;'; 124 209 $_GET['nolog'] = 1; 125 210 if ($db->PConnect($myDSN, "", "", "")) { 126 211 print "ADO version=".$db->_connectionID->version."<br>"; … … 138 223 } else print "ERROR: Visual FoxPro test requires a Windows ODBC DSN=vfp-adoxyz, VFP driver"; 139 224 225 echo "<hr />"; 226 $db = &ADONewConnection('odbtp'); 227 228 if ( $db->PConnect('localhost','DRIVER={Microsoft Visual FoxPro Driver};SOURCETYPE=DBF;SOURCEDB=d:\inetpub\adodb;EXCLUSIVE=NO;')) { 229 print "<h1>Connecting $db->databaseType...</h1>";flush(); 230 testdb($db,"create table d:\\inetpub\\adodb\\ADOXYZ (id int, firstname char(24), lastname char(24),created date)"); 231 } else print "ERROR: Visual FoxPro odbtp requires a Windows ODBC DSN=vfp-adoxyz, VFP driver"; 232 140 233 } 141 234 … … 145 238 146 239 147 if (PHP_VERSION >= 5 || $ HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost';240 if (PHP_VERSION >= 5 || $_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost'; 148 241 else $server = "mangrove"; 149 242 $user = 'root'; $password = ''; $database = 'northwind'; 150 $db = &ADONewConnection("mysql ://$user:$password@$server/$database?persist");243 $db = &ADONewConnection("mysqlt://$user:$password@$server/$database?persist"); 151 244 print "<h1>Connecting $db->databaseType...</h1>"; 152 245 153 246 if (true || $db->PConnect($server, "root", "", "northwind")) { 247 //$db->Execute("DROP TABLE ADOXYZ") || die('fail drop'); 154 248 //$db->debug=1;$db->Execute('drop table ADOXYZ'); 155 249 testdb($db, 156 "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) ");250 "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) Type=InnoDB"); 157 251 } else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg(); 158 252 } … … 163 257 $db = &ADONewConnection('mysqli'); 164 258 print "<h1>Connecting $db->databaseType...</h1>"; 165 if (PHP_VERSION >= 5 || $ HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost';259 if (PHP_VERSION >= 5 || $_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost'; 166 260 else $server = "mangrove"; 167 261 if ($db->PConnect($server, "root", "", "northwind")) { … … 179 273 $db->hasTransactions = false; 180 274 print "<h1>Connecting $db->databaseType...</h1>"; 181 if ($ HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost';275 if ($_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost'; 182 276 else $server = "mangrove"; 183 277 if ($db->PConnect('mysql', "root", "")) … … 190 284 $db = &ADONewConnection('proxy'); 191 285 print "<h1>Connecting $db->databaseType...</h1>"; 192 if ($ HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost';286 if ($_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost'; 193 287 194 288 if ($db->PConnect('http://localhost/php/phplens/adodb/server.php')) … … 201 295 ADOLoadCode('oci805'); 202 296 ADOLoadCode("oci8po"); 297 203 298 if (!empty($testoracle)) { 204 $dsn = "oci8po://scott:natsoft@panther?persist"; 205 $db = ADONewConnection($dsn); 299 $dsn = "oci8po://juris10:natsoft@sherkhan?persist"; 300 $db = ADONewConnection($dsn );//'oci8'); 301 302 //$db->debug=1; 206 303 print "<h1>Connecting $db->databaseType...</h1>"; 207 304 if (true || $db->Connect('', "scott", "natsoft",'')) 208 305 testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); 209 else print "ERROR: Oracle test requires an Oracle server setup with scott/natsoft".'<BR>'.$db->ErrorMsg(); 306 else 307 print "ERROR: Oracle test requires an Oracle server setup with scott/natsoft".'<BR>'.$db->ErrorMsg(); 210 308 211 309 } … … 221 319 } 222 320 223 ADOLoadCode("db2"); // no longer supported 224 if (!empty($testdb2)) { 225 226 $db = ADONewConnection(); 227 print "<h1>Connecting $db->databaseType...</h1>"; 228 if ($db->Connect("db2_sample", "root", "natsoft", "")) 321 ADOLoadCode("odbc_db2"); // no longer supported 322 if (!empty($testdb2)) { 323 if (PHP_VERSION>=5.1) { 324 $db = ADONewConnection("db2"); 325 print "<h1>Connecting $db->databaseType...</h1>"; 326 327 #$db->curMode = SQL_CUR_USE_ODBC; 328 #$dsn = "driver={IBM db2 odbc DRIVER};Database=test;hostname=localhost;port=50000;protocol=TCPIP; uid=natsoft; pwd=guest"; 329 if ($db->Connect('localhost','natsoft','guest','test')) { 330 testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); 331 } else print "ERROR: DB2 test requires an server setup with odbc data source db2_sample".'<BR>'.$db->ErrorMsg(); 332 } else { 333 $db = ADONewConnection("odbc_db2"); 334 print "<h1>Connecting $db->databaseType...</h1>"; 335 336 $dsn = "db2test"; 337 #$db->curMode = SQL_CUR_USE_ODBC; 338 #$dsn = "driver={IBM db2 odbc DRIVER};Database=test;hostname=localhost;port=50000;protocol=TCPIP; uid=natsoft; pwd=guest"; 339 if ($db->Connect($dsn)) { 340 testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); 341 } else print "ERROR: DB2 test requires an server setup with odbc data source db2_sample".'<BR>'.$db->ErrorMsg(); 342 } 343 echo "<hr />"; 344 flush(); 345 $dsn = "driver={IBM db2 odbc DRIVER};Database=sample;hostname=localhost;port=50000;protocol=TCPIP; uid=root; pwd=natsoft"; 346 347 $db = ADONewConnection('odbtp'); 348 if ($db->Connect('127.0.0.1',$dsn)) { 349 350 $db->debug=1; 351 $arr = $db->GetArray( "||SQLProcedures" ); adodb_pr($arr); 352 $arr = $db->GetArray( "||SQLProcedureColumns|||GET_ROUTINE_SAR" );adodb_pr($arr); 353 229 354 testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); 230 else print "ERROR: DB2 test requires an server setup with odbc data source db2_sample".'<BR>'.$db->ErrorMsg(); 231 355 } else echo ("ERROR Connection"); 356 echo $db->ErrorMsg(); 357 } 358 359 360 $server = 'sherkhan'; 361 362 363 364 ADOLoadCode("mssqlpo"); 365 if (!empty($testmssql)) { // MS SQL Server -- the extension is buggy -- probably better to use ODBC 366 $db = ADONewConnection("mssqlpo"); 367 //$db->debug=1; 368 print "<h1>Connecting $db->databaseType...</h1>"; 369 370 $ok = $db->Connect('','adodb','natsoft','northwind'); 371 372 if ($ok or $db->PConnect("mangrove", "sa", "natsoft", "ai")) { 373 AutoDetect_MSSQL_Date_Order($db); 374 // $db->Execute('drop table adoxyz'); 375 testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)"); 376 } else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='192.168.0.1', userid='adodb', password='natsoft', database='ai'".'<BR>'.$db->ErrorMsg(); 377 232 378 } 233 379 … … 239 385 print "<h1>Connecting $db->databaseType...</h1>"; 240 386 241 $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server= localhost;Database=northwind;";387 $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=$server;Database=northwind;"; 242 388 243 389 if ($db->PConnect($dsn, "adodb", "natsoft", "")) { … … 249 395 250 396 ADOLoadCode("ado_mssql"); 251 252 397 if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC -- DSN-less 253 398 … … 257 402 258 403 $myDSN="PROVIDER=MSDASQL;DRIVER={SQL Server};" 259 . "SERVER= tigress;DATABASE=NorthWind;UID=adodb;PWD=natsoft;Trusted_Connection=No";404 . "SERVER=$server;DATABASE=NorthWind;UID=adodb;PWD=natsoft;Trusted_Connection=No"; 260 405 261 406 … … 266 411 } 267 412 268 269 ADOLoadCode("mssqlpo");270 if (!empty($testmssql)) { // MS SQL Server -- the extension is buggy -- probably better to use ODBC271 $db = ADONewConnection("mssqlpo");272 //$db->debug=1;273 print "<h1>Connecting $db->databaseType...</h1>";274 275 $ok = $db->PConnect('tigress','adodb','natsoft','northwind');276 277 if ($ok or $db->PConnect("mangrove", "sa", "natsoft", "ai")) {278 AutoDetect_MSSQL_Date_Order($db);279 // $db->Execute('drop table adoxyz');280 testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");281 } else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='192.168.0.1', userid='sa', password='natsoft', database='ai'".'<BR>'.$db->ErrorMsg();282 283 }284 285 413 if (!empty($testmssql) && !empty($testado)) { // ADO ACCESS MSSQL with OLEDB provider 286 414 … … 288 416 print "<h1>Connecting DSN-less OLEDB Provider $db->databaseType...</h1>"; 289 417 //$db->debug=1; 290 $myDSN="SERVER= tigress;DATABASE=northwind;Trusted_Connection=yes";291 if ($db->PConnect($myDSN, "adodb", "natsoft", 'SQLOLEDB')) 418 $myDSN="SERVER=localhost;DATABASE=northwind;Trusted_Connection=yes"; 419 if ($db->PConnect($myDSN, "adodb", "natsoft", 'SQLOLEDB')) { 292 420 testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)"); 293 else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='mangrove', userid='sa', password='', database='ai'"; 421 } else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='mangrove', userid='sa', password='', database='ai'"; 422 423 } 424 425 426 if (extension_loaded('odbtp') && !empty($testmssql)) { // MS SQL Server via ODBC 427 $db = ADONewConnection('odbtp'); 428 429 $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=$server;Database=northwind;uid=adodb;pwd=natsoft"; 430 431 if ($db->PConnect('localhost',$dsn, "", "")) { 432 print "<h1>Connecting $db->databaseType...</h1>"; 433 testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)"); 434 } 435 else print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN setup"; 294 436 295 437 }
Note: See TracChangeset
for help on using the changeset viewer.