Ignore:
Timestamp:
06/29/07 15:17:46 (17 years ago)
Author:
niltonneto
Message:

Versão nova do ADODB (4.5 para 4.95)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpgwapi/inc/adodb/tests/testdatabases.inc.php

    r2 r34  
    22   
    33/* 
    4 V4.51 29 July 2004  (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved. 
     4V4.80 8 Mar 2006  (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. 
    55  Released under both BSD license and Lesser GPL library license.  
    66  Whenever there is any discrepancy between the two licenses,  
     
    1818 <input type=checkbox name="testmysql" value=1 <?php echo !empty($testmysql) ? 'checked' : '' ?>> <b>MySQL</b><br> 
    1919<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> 
    2022<td><input type=checkbox name="testsqlite" value=1 <?php echo !empty($testsqlite) ? 'checked' : '' ?>> <b>SQLite</b><br> 
    2123<input type=checkbox name="testproxy" value=1 <?php echo !empty($testproxy) ? 'checked' : '' ?>> <b>MySQL Proxy</b><br> 
     
    2325<input type=checkbox name="testpostgres" value=1 <?php echo !empty($testpostgres) ? 'checked' : '' ?>> <b>PostgreSQL</b><br> 
    2426<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 
    2536<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> 
    2738<input type=checkbox name="testado" value=1 <?php echo !empty($testado) ? 'checked' : '' ?>> ADO (for mssql and access)<br> 
    2839<input type=checkbox name="nocountrecs" value=1 <?php echo !empty($nocountrecs) ? 'checked' : '' ?>> $ADODB_COUNTRECS=false<br> 
    2940<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> 
    3144</form> 
    32 </table> 
     45 
    3346<?php 
    3447 
     
    4255if (!strpos(PHP_VERSION,'5') === 0) { 
    4356        ADOLoadCode("sybase"); 
    44         ADOLoadCode("postgres"); 
    45         ADOLoadCode("postgres7"); 
     57        //ADOLoadCode("postgres"); 
     58        //ADOLoadCode("postgres7"); 
    4659        ADOLoadCode("firebird"); 
    4760        ADOLoadCode("borland_ibase"); 
     
    8194        $db = &ADONewConnection('firebird'); 
    8295        print "<h1>Connecting $db->databaseType...</h1>"; 
    83         if ($db->PConnect("localhost:d:\\firebird\\10\\examples\\employee.gdb", "sysdba", "masterkey", "")) 
     96        if ($db->PConnect("localhost:d:\\firebird\\151\\examples\\EMPLOYEE.fdb", "sysdba", "masterkey", "")) 
    8497                testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname char(24),price numeric(12,2),created date)"); 
    8598         else print "ERROR: Interbase test requires a database called employee.gdb".'<BR>'.$db->ErrorMsg(); 
     
    89102 
    90103if (!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>"; 
    95114                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 
     120if (!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 
     130if (!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 
     141if (!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 
     152if (!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 
     163if (!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 
     174if (!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)"); 
    98183} 
    99184 
     
    122207                . 'DATA SOURCE=' . $access . ';'; 
    123208                //. 'USER ID=;PASSWORD=;'; 
    124          
     209        $_GET['nolog'] = 1; 
    125210        if ($db->PConnect($myDSN, "", "", "")) { 
    126211                print "ADO version=".$db->_connectionID->version."<br>"; 
     
    138223         } else print "ERROR: Visual FoxPro test requires a Windows ODBC DSN=vfp-adoxyz, VFP driver"; 
    139224         
     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         
    140233} 
    141234 
     
    145238 
    146239 
    147         if (PHP_VERSION >= 5 || $HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost'; 
     240        if (PHP_VERSION >= 5 || $_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost'; 
    148241        else $server = "mangrove"; 
    149242        $user = 'root'; $password = ''; $database = 'northwind'; 
    150         $db = &ADONewConnection("mysql://$user:$password@$server/$database?persist"); 
     243        $db = &ADONewConnection("mysqlt://$user:$password@$server/$database?persist"); 
    151244        print "<h1>Connecting $db->databaseType...</h1>"; 
    152245         
    153246        if (true || $db->PConnect($server, "root", "", "northwind")) { 
     247                //$db->Execute("DROP TABLE ADOXYZ") || die('fail drop'); 
    154248                //$db->debug=1;$db->Execute('drop table ADOXYZ'); 
    155249                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"); 
    157251        } else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg(); 
    158252} 
     
    163257        $db = &ADONewConnection('mysqli'); 
    164258        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'; 
    166260        else $server = "mangrove"; 
    167261        if ($db->PConnect($server, "root", "", "northwind")) { 
     
    179273        $db->hasTransactions = false; 
    180274        print "<h1>Connecting $db->databaseType...</h1>"; 
    181         if ($HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost'; 
     275        if ($_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost'; 
    182276        else $server = "mangrove"; 
    183277        if ($db->PConnect('mysql', "root", "")) 
     
    190284        $db = &ADONewConnection('proxy'); 
    191285        print "<h1>Connecting $db->databaseType...</h1>"; 
    192         if ($HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost'; 
     286        if ($_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost'; 
    193287 
    194288        if ($db->PConnect('http://localhost/php/phplens/adodb/server.php')) 
     
    201295ADOLoadCode('oci805'); 
    202296ADOLoadCode("oci8po"); 
     297         
    203298if (!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; 
    206303        print "<h1>Connecting $db->databaseType...</h1>"; 
    207304        if (true || $db->Connect('', "scott", "natsoft",'')) 
    208305                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(); 
    210308 
    211309} 
     
    221319} 
    222320 
    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", "")) 
     321ADOLoadCode("odbc_db2"); // no longer supported 
     322if (!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        } 
     343echo "<hr />"; 
     344flush(); 
     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         
    229354                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 
     364ADOLoadCode("mssqlpo"); 
     365if (!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         
    232378} 
    233379 
     
    239385        print "<h1>Connecting $db->databaseType...</h1>"; 
    240386         
    241         $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=localhost;Database=northwind;"; 
     387        $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=$server;Database=northwind;"; 
    242388         
    243389        if ($db->PConnect($dsn, "adodb", "natsoft", ""))  { 
     
    249395 
    250396ADOLoadCode("ado_mssql"); 
    251  
    252397if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC -- DSN-less 
    253398         
     
    257402         
    258403        $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"; 
    260405 
    261406                 
     
    266411} 
    267412 
    268  
    269 ADOLoadCode("mssqlpo"); 
    270 if (!empty($testmssql)) { // MS SQL Server -- the extension is buggy -- probably better to use ODBC 
    271         $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  
    285413if (!empty($testmssql) && !empty($testado)) { // ADO ACCESS MSSQL with OLEDB provider 
    286414 
     
    288416        print "<h1>Connecting DSN-less OLEDB Provider $db->databaseType...</h1>"; 
    289417        //$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')) { 
    292420                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 
     426if (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"; 
    294436 
    295437} 
Note: See TracChangeset for help on using the changeset viewer.