[6779] | 1 | <?php |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | V4.80 8 Mar 2006 (c) 2000-2007 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 | |
---|
| 298 | if (!empty($testoracle)) { |
---|
| 299 | $dsn = "oci8po://juris10:natsoft@sherkhan?persist"; |
---|
| 300 | $db = ADONewConnection($dsn );//'oci8'); |
---|
| 301 | |
---|
| 302 | //$db->debug=1; |
---|
| 303 | print "<h1>Connecting $db->databaseType...</h1>"; |
---|
| 304 | if (true || $db->Connect('', "scott", "natsoft",'')) |
---|
| 305 | testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); |
---|
| 306 | else |
---|
| 307 | print "ERROR: Oracle test requires an Oracle server setup with scott/natsoft".'<BR>'.$db->ErrorMsg(); |
---|
| 308 | |
---|
| 309 | } |
---|
| 310 | ADOLoadCode("oracle"); // no longer supported |
---|
| 311 | if (false && !empty($testoracle)) { |
---|
| 312 | |
---|
| 313 | $db = ADONewConnection(); |
---|
| 314 | print "<h1>Connecting $db->databaseType...</h1>"; |
---|
| 315 | if ($db->PConnect("", "scott", "tiger", "natsoft.domain")) |
---|
| 316 | testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); |
---|
| 317 | else print "ERROR: Oracle test requires an Oracle server setup with scott/tiger".'<BR>'.$db->ErrorMsg(); |
---|
| 318 | |
---|
| 319 | } |
---|
| 320 | |
---|
| 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 | |
---|
| 354 | testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); |
---|
| 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 | |
---|
| 378 | } |
---|
| 379 | |
---|
| 380 | |
---|
| 381 | ADOLoadCode('odbc_mssql'); |
---|
| 382 | if (!empty($testmssql)) { // MS SQL Server via ODBC |
---|
| 383 | $db = ADONewConnection(); |
---|
| 384 | |
---|
| 385 | print "<h1>Connecting $db->databaseType...</h1>"; |
---|
| 386 | |
---|
| 387 | $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=$server;Database=northwind;"; |
---|
| 388 | |
---|
| 389 | if ($db->PConnect($dsn, "adodb", "natsoft", "")) { |
---|
| 390 | testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)"); |
---|
| 391 | } |
---|
| 392 | else print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN setup"; |
---|
| 393 | |
---|
| 394 | } |
---|
| 395 | |
---|
| 396 | ADOLoadCode("ado_mssql"); |
---|
| 397 | if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC -- DSN-less |
---|
| 398 | |
---|
| 399 | $db = &ADONewConnection("ado_mssql"); |
---|
| 400 | //$db->debug=1; |
---|
| 401 | print "<h1>Connecting DSN-less $db->databaseType...</h1>"; |
---|
| 402 | |
---|
| 403 | $myDSN="PROVIDER=MSDASQL;DRIVER={SQL Server};" |
---|
| 404 | . "SERVER=$server;DATABASE=NorthWind;UID=adodb;PWD=natsoft;Trusted_Connection=No"; |
---|
| 405 | |
---|
| 406 | |
---|
| 407 | if ($db->PConnect($myDSN, "", "", "")) |
---|
| 408 | testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)"); |
---|
| 409 | else print "ERROR: MSSQL test 2 requires MS SQL 7"; |
---|
| 410 | |
---|
| 411 | } |
---|
| 412 | |
---|
| 413 | if (!empty($testmssql) && !empty($testado)) { // ADO ACCESS MSSQL with OLEDB provider |
---|
| 414 | |
---|
| 415 | $db = &ADONewConnection("ado_mssql"); |
---|
| 416 | print "<h1>Connecting DSN-less OLEDB Provider $db->databaseType...</h1>"; |
---|
| 417 | //$db->debug=1; |
---|
| 418 | $myDSN="SERVER=localhost;DATABASE=northwind;Trusted_Connection=yes"; |
---|
| 419 | if ($db->PConnect($myDSN, "adodb", "natsoft", 'SQLOLEDB')) { |
---|
| 420 | testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)"); |
---|
| 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"; |
---|
| 436 | |
---|
| 437 | } |
---|
| 438 | |
---|
| 439 | |
---|
| 440 | print "<h3>Tests Completed</h3>"; |
---|
| 441 | |
---|
| 442 | ?> |
---|