[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 3 /* 4 V4.80 8 Mar 2006 (c) 2000-2006 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 10 /* this file is used by the ADODB test program: test.php */ 11 ?> 12 13 <table><tr valign=top><td> 14 <form method=get> 15 <input type=checkbox name="testaccess" value=1 <?php echo !empty($testaccess) ? 'checked' : '' ?>> <b>Access</b><br> 16 <input type=checkbox name="testibase" value=1 <?php echo !empty($testibase) ? 'checked' : '' ?>> <b>Interbase</b><br> 17 <input type=checkbox name="testmssql" value=1 <?php echo !empty($testmssql) ? 'checked' : '' ?>> <b>MSSQL</b><br> 18 <input type=checkbox name="testmysql" value=1 <?php echo !empty($testmysql) ? 'checked' : '' ?>> <b>MySQL</b><br> 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> 22 <td><input type=checkbox name="testsqlite" value=1 <?php echo !empty($testsqlite) ? 'checked' : '' ?>> <b>SQLite</b><br> 23 <input type=checkbox name="testproxy" value=1 <?php echo !empty($testproxy) ? 'checked' : '' ?>> <b>MySQL Proxy</b><br> 24 <input type=checkbox name="testoracle" value=1 <?php echo !empty($testoracle) ? 'checked' : '' ?>> <b>Oracle (oci8)</b> <br> 25 <input type=checkbox name="testpostgres" value=1 <?php echo !empty($testpostgres) ? 'checked' : '' ?>> <b>PostgreSQL</b><br> 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 36 <td><input type=checkbox name="testdb2" value=1 <?php echo !empty($testdb2) ? 'checked' : '' ?>> DB2<br> 37 <input type=checkbox name="testvfp" value=1 <?php echo !empty($testvfp) ? 'checked' : '' ?>> VFP+ODBTP<br> 38 <input type=checkbox name="testado" value=1 <?php echo !empty($testado) ? 'checked' : '' ?>> ADO (for mssql and access)<br> 39 <input type=checkbox name="nocountrecs" value=1 <?php echo !empty($nocountrecs) ? 'checked' : '' ?>> $ADODB_COUNTRECS=false<br> 40 <input type=checkbox name="nolog" value=1 <?php echo !empty($nolog) ? 'checked' : '' ?>> No SQL Logging<br> 41 <input type=checkbox name="time" value=1 <?php echo !empty($_GET['time']) ? 'checked' : '' ?>> ADOdb time test 42 </table> 43 <input type=submit> 44 </form> 45 46 <?php 47 48 if ($ADODB_FETCH_MODE != ADODB_FETCH_DEFAULT) print "<h3>FETCH MODE IS NOT ADODB_FETCH_DEFAULT</h3>"; 49 50 if (isset($nocountrecs)) $ADODB_COUNTRECS = false; 51 52 // cannot test databases below, but we include them anyway to check 53 // if they parse ok... 54 55 if (!strpos(PHP_VERSION,'5') === 0) { 56 ADOLoadCode("sybase"); 57 //ADOLoadCode("postgres"); 58 //ADOLoadCode("postgres7"); 59 ADOLoadCode("firebird"); 60 ADOLoadCode("borland_ibase"); 61 ADOLoadCode("informix"); 62 ADOLoadCode("sqlanywhere"); 63 // ADOLoadCode('mysqli'); 64 } 65 66 67 flush(); 68 if (!empty($testpostgres)) { 69 //ADOLoadCode("postgres"); 70 71 $db = &ADONewConnection('postgres'); 72 print "<h1>Connecting $db->databaseType...</h1>"; 73 if ($db->Connect("localhost","tester","test","test")) { 74 testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname varchar,created date)"); 75 }else 76 print "ERROR: PostgreSQL requires a database called test on server, user tester, password test.<BR>".$db->ErrorMsg(); 77 } 78 79 if (!empty($testpgodbc)) { 80 81 $db = &ADONewConnection('odbc'); 82 $db->hasTransactions = false; 83 print "<h1>Connecting $db->databaseType...</h1>"; 84 85 if ($db->PConnect('Postgresql')) { 86 $db->hasTransactions = true; 87 testdb($db, 88 "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) type=innodb"); 89 } else print "ERROR: PostgreSQL requires a database called test on server, user tester, password test.<BR>".$db->ErrorMsg(); 90 } 91 92 if (!empty($testibase)) { 93 //$_GET['nolog'] = true; 94 $db = &ADONewConnection('firebird'); 95 print "<h1>Connecting $db->databaseType...</h1>"; 96 if ($db->PConnect("localhost:d:\\firebird\\151\\examples\\EMPLOYEE.fdb", "sysdba", "masterkey", "")) 97 testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname char(24),price numeric(12,2),created date)"); 98 else print "ERROR: Interbase test requires a database called employee.gdb".'<BR>'.$db->ErrorMsg(); 99 100 } 101 102 103 if (!empty($testsqlite)) { 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>"; 114 testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)"); 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)"); 183 } 184 185 // REQUIRES ODBC DSN CALLED nwind 186 if (!empty($testaccess)) { 187 $db = &ADONewConnection('access'); 188 print "<h1>Connecting $db->databaseType...</h1>"; 189 $access = 'd:\inetpub\wwwroot\php\NWIND.MDB'; 190 $dsn = "nwind"; 191 $dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=$access;Uid=Admin;Pwd=;"; 192 193 //$dsn = 'Provider=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=' . $access . ';'; 194 if ($db->PConnect($dsn, "", "", "")) 195 testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)"); 196 else print "ERROR: Access test requires a Windows ODBC DSN=nwind, Access driver"; 197 198 } 199 200 if (!empty($testaccess) && !empty($testado)) { // ADO ACCESS 201 202 $db = &ADONewConnection("ado_access"); 203 print "<h1>Connecting $db->databaseType...</h1>"; 204 205 $access = 'd:\inetpub\wwwroot\php\NWIND.MDB'; 206 $myDSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;' 207 . 'DATA SOURCE=' . $access . ';'; 208 //. 'USER ID=;PASSWORD=;'; 209 $_GET['nolog'] = 1; 210 if ($db->PConnect($myDSN, "", "", "")) { 211 print "ADO version=".$db->_connectionID->version."<br>"; 212 testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)"); 213 } else print "ERROR: Access test requires a Access database $access".'<BR>'.$db->ErrorMsg(); 214 215 } 216 217 if (!empty($testvfp)) { // ODBC 218 $db = &ADONewConnection('vfp'); 219 print "<h1>Connecting $db->databaseType...</h1>";flush(); 220 221 if ( $db->PConnect("vfp-adoxyz")) { 222 testdb($db,"create table d:\\inetpub\\adodb\\ADOXYZ (id int, firstname char(24), lastname char(24),created date)"); 223 } else print "ERROR: Visual FoxPro test requires a Windows ODBC DSN=vfp-adoxyz, VFP driver"; 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 233 } 234 235 236 // REQUIRES MySQL server at localhost with database 'test' 237 if (!empty($testmysql)) { // MYSQL 238 239 240 if (PHP_VERSION >= 5 || $_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost'; 241 else $server = "mangrove"; 242 $user = 'root'; $password = ''; $database = 'northwind'; 243 $db = &ADONewConnection("mysqlt://$user:$password@$server/$database?persist"); 244 print "<h1>Connecting $db->databaseType...</h1>"; 245 246 if (true || $db->PConnect($server, "root", "", "northwind")) { 247 //$db->Execute("DROP TABLE ADOXYZ") || die('fail drop'); 248 //$db->debug=1;$db->Execute('drop table ADOXYZ'); 249 testdb($db, 250 "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) Type=InnoDB"); 251 } else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg(); 252 } 253 254 // REQUIRES MySQL server at localhost with database 'test' 255 if (!empty($testmysqli)) { // MYSQL 256 257 $db = &ADONewConnection('mysqli'); 258 print "<h1>Connecting $db->databaseType...</h1>"; 259 if (PHP_VERSION >= 5 || $_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost'; 260 else $server = "mangrove"; 261 if ($db->PConnect($server, "root", "", "northwind")) { 262 //$db->debug=1;$db->Execute('drop table ADOXYZ'); 263 testdb($db, 264 "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); 265 } else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg(); 266 } 267 268 269 // REQUIRES MySQL server at localhost with database 'test' 270 if (!empty($testmysqlodbc)) { // MYSQL 271 272 $db = &ADONewConnection('odbc'); 273 $db->hasTransactions = false; 274 print "<h1>Connecting $db->databaseType...</h1>"; 275 if ($_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost'; 276 else $server = "mangrove"; 277 if ($db->PConnect('mysql', "root", "")) 278 testdb($db, 279 "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) type=innodb"); 280 else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg(); 281 } 282 283 if (!empty($testproxy)){ 284 $db = &ADONewConnection('proxy'); 285 print "<h1>Connecting $db->databaseType...</h1>"; 286 if ($_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost'; 287 288 if ($db->PConnect('http://localhost/php/phplens/adodb/server.php')) 289 testdb($db, 290 "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) type=innodb"); 291 else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg(); 292 293 } 294 295 ADOLoadCode('oci805'); 296 ADOLoadCode("oci8po"); 297 if (!empty($testoracle)) { 298 $dsn = "oci8po://juris10:natsoft@sherkhan?persist"; 299 $db = ADONewConnection($dsn); 300 print "<h1>Connecting $db->databaseType...</h1>"; 301 if (true || $db->Connect('', "scott", "natsoft",'')) 302 testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); 303 else print "ERROR: Oracle test requires an Oracle server setup with scott/natsoft".'<BR>'.$db->ErrorMsg(); 304 305 } 306 ADOLoadCode("oracle"); // no longer supported 307 if (false && !empty($testoracle)) { 308 309 $db = ADONewConnection(); 310 print "<h1>Connecting $db->databaseType...</h1>"; 311 if ($db->PConnect("", "scott", "tiger", "natsoft.domain")) 312 testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); 313 else print "ERROR: Oracle test requires an Oracle server setup with scott/tiger".'<BR>'.$db->ErrorMsg(); 314 315 } 316 317 ADOLoadCode("odbc_db2"); // no longer supported 318 if (!empty($testdb2)) { 319 if (PHP_VERSION>=5.1) { 320 $db = ADONewConnection("db2"); 321 print "<h1>Connecting $db->databaseType...</h1>"; 322 323 #$db->curMode = SQL_CUR_USE_ODBC; 324 #$dsn = "driver={IBM db2 odbc DRIVER};Database=test;hostname=localhost;port=50000;protocol=TCPIP; uid=natsoft; pwd=guest"; 325 if ($db->Connect('localhost','natsoft','guest','test')) { 326 testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); 327 } else print "ERROR: DB2 test requires an server setup with odbc data source db2_sample".'<BR>'.$db->ErrorMsg(); 328 } else { 329 $db = ADONewConnection("odbc_db2"); 330 print "<h1>Connecting $db->databaseType...</h1>"; 331 332 $dsn = "db2test"; 333 #$db->curMode = SQL_CUR_USE_ODBC; 334 #$dsn = "driver={IBM db2 odbc DRIVER};Database=test;hostname=localhost;port=50000;protocol=TCPIP; uid=natsoft; pwd=guest"; 335 if ($db->Connect($dsn)) { 336 testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); 337 } else print "ERROR: DB2 test requires an server setup with odbc data source db2_sample".'<BR>'.$db->ErrorMsg(); 338 } 339 echo "<hr />"; 340 flush(); 341 $dsn = "driver={IBM db2 odbc DRIVER};Database=sample;hostname=localhost;port=50000;protocol=TCPIP; uid=root; pwd=natsoft"; 342 343 $db = ADONewConnection('odbtp'); 344 if ($db->Connect('127.0.0.1',$dsn)) { 345 346 $db->debug=1; 347 $arr = $db->GetArray( "||SQLProcedures" ); adodb_pr($arr); 348 $arr = $db->GetArray( "||SQLProcedureColumns|||GET_ROUTINE_SAR" );adodb_pr($arr); 349 350 testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); 351 } else echo ("ERROR Connection"); 352 echo $db->ErrorMsg(); 353 } 354 355 356 $server = 'sherkhan'; 357 358 359 360 ADOLoadCode("mssqlpo"); 361 if (!empty($testmssql)) { // MS SQL Server -- the extension is buggy -- probably better to use ODBC 362 $db = ADONewConnection("mssqlpo"); 363 //$db->debug=1; 364 print "<h1>Connecting $db->databaseType...</h1>"; 365 366 $ok = $db->Connect('','adodb','natsoft','northwind'); 367 368 if ($ok or $db->PConnect("mangrove", "sa", "natsoft", "ai")) { 369 AutoDetect_MSSQL_Date_Order($db); 370 // $db->Execute('drop table adoxyz'); 371 testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)"); 372 } 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(); 373 374 } 375 376 377 ADOLoadCode('odbc_mssql'); 378 if (!empty($testmssql)) { // MS SQL Server via ODBC 379 $db = ADONewConnection(); 380 381 print "<h1>Connecting $db->databaseType...</h1>"; 382 383 $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=$server;Database=northwind;"; 384 385 if ($db->PConnect($dsn, "adodb", "natsoft", "")) { 386 testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)"); 387 } 388 else print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN setup"; 389 390 } 391 392 ADOLoadCode("ado_mssql"); 393 if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC -- DSN-less 394 395 $db = &ADONewConnection("ado_mssql"); 396 //$db->debug=1; 397 print "<h1>Connecting DSN-less $db->databaseType...</h1>"; 398 399 $myDSN="PROVIDER=MSDASQL;DRIVER={SQL Server};" 400 . "SERVER=$server;DATABASE=NorthWind;UID=adodb;PWD=natsoft;Trusted_Connection=No"; 401 402 403 if ($db->PConnect($myDSN, "", "", "")) 404 testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)"); 405 else print "ERROR: MSSQL test 2 requires MS SQL 7"; 406 407 } 408 409 if (!empty($testmssql) && !empty($testado)) { // ADO ACCESS MSSQL with OLEDB provider 410 411 $db = &ADONewConnection("ado_mssql"); 412 print "<h1>Connecting DSN-less OLEDB Provider $db->databaseType...</h1>"; 413 //$db->debug=1; 414 $myDSN="SERVER=localhost;DATABASE=northwind;Trusted_Connection=yes"; 415 if ($db->PConnect($myDSN, "adodb", "natsoft", 'SQLOLEDB')) { 416 testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)"); 417 } else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='mangrove', userid='sa', password='', database='ai'"; 418 419 } 420 421 422 if (extension_loaded('odbtp') && !empty($testmssql)) { // MS SQL Server via ODBC 423 $db = ADONewConnection('odbtp'); 424 425 $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=$server;Database=northwind;uid=adodb;pwd=natsoft"; 426 427 if ($db->PConnect('localhost',$dsn, "", "")) { 428 print "<h1>Connecting $db->databaseType...</h1>"; 429 testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)"); 430 } 431 else print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN setup"; 432 433 } 434 435 436 print "<h3>Tests Completed</h3>"; 437 438 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |