source: trunk/phpgwapi/inc/adodb/tests/testdatabases.inc.php @ 2

Revision 2, 12.0 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2 
3/*
4V4.51 29 July 2004  (c) 2000-2004 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<td><input type=checkbox name="testsqlite" value=1 <?php echo !empty($testsqlite) ? 'checked' : '' ?>> <b>SQLite</b><br>
21<input type=checkbox name="testproxy" value=1 <?php echo !empty($testproxy) ? 'checked' : '' ?>> <b>MySQL Proxy</b><br>
22<input type=checkbox name="testoracle" value=1 <?php echo !empty($testoracle) ? 'checked' : '' ?>> <b>Oracle (oci8)</b> <br>
23<input type=checkbox name="testpostgres" value=1 <?php echo !empty($testpostgres) ? 'checked' : '' ?>> <b>PostgreSQL</b><br>
24<input type=checkbox name="testpgodbc" value=1 <?php echo !empty($testpgodbc) ? 'checked' : '' ?>> <b>PostgreSQL ODBC</b><br>
25<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>
27<input type=checkbox name="testado" value=1 <?php echo !empty($testado) ? 'checked' : '' ?>> ADO (for mssql and access)<br>
28<input type=checkbox name="nocountrecs" value=1 <?php echo !empty($nocountrecs) ? 'checked' : '' ?>> $ADODB_COUNTRECS=false<br>
29<input type=checkbox name="nolog" value=1 <?php echo !empty($nolog) ? 'checked' : '' ?>> No SQL Logging<br>
30<td><input type=submit>
31</form>
32</table>
33<?php
34
35if ($ADODB_FETCH_MODE != ADODB_FETCH_DEFAULT) print "<h3>FETCH MODE IS NOT ADODB_FETCH_DEFAULT</h3>";
36
37if (isset($nocountrecs)) $ADODB_COUNTRECS = false;
38
39// cannot test databases below, but we include them anyway to check
40// if they parse ok...
41
42if (!strpos(PHP_VERSION,'5') === 0) {
43        ADOLoadCode("sybase");
44        ADOLoadCode("postgres");
45        ADOLoadCode("postgres7");
46        ADOLoadCode("firebird");
47        ADOLoadCode("borland_ibase");
48        ADOLoadCode("informix");
49        ADOLoadCode("sqlanywhere");
50//      ADOLoadCode('mysqli');
51}
52
53
54flush();
55if (!empty($testpostgres)) {
56        //ADOLoadCode("postgres");
57
58        $db = &ADONewConnection('postgres');
59        print "<h1>Connecting $db->databaseType...</h1>";
60        if ($db->Connect("localhost","tester","test","test")) {
61                testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname varchar,created date)");
62        }else
63                print "ERROR: PostgreSQL requires a database called test on server, user tester, password test.<BR>".$db->ErrorMsg();
64}
65
66if (!empty($testpgodbc)) {
67       
68        $db = &ADONewConnection('odbc');
69        $db->hasTransactions = false;
70        print "<h1>Connecting $db->databaseType...</h1>";
71       
72        if ($db->PConnect('Postgresql')) {
73                $db->hasTransactions = true;
74                testdb($db,
75                "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) type=innodb");
76        } else print "ERROR: PostgreSQL requires a database called test on server, user tester, password test.<BR>".$db->ErrorMsg();
77}
78
79if (!empty($testibase)) {
80        //$_GET['nolog'] = true;
81        $db = &ADONewConnection('firebird');
82        print "<h1>Connecting $db->databaseType...</h1>";
83        if ($db->PConnect("localhost:d:\\firebird\\10\\examples\\employee.gdb", "sysdba", "masterkey", ""))
84                testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname char(24),price numeric(12,2),created date)");
85         else print "ERROR: Interbase test requires a database called employee.gdb".'<BR>'.$db->ErrorMsg();
86       
87}
88
89
90if (!empty($testsqlite)) {
91        $db = &ADONewConnection('sqlite');
92        print "<h1>Connecting $db->databaseType...</h1>";
93       
94        if ($db->PConnect("d:\\inetpub\\adodb\\sqlite.db", "", "", ""))
95                testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
96        else print "ERROR: SQLite";
97       
98}
99
100// REQUIRES ODBC DSN CALLED nwind
101if (!empty($testaccess)) {
102        $db = &ADONewConnection('access');
103        print "<h1>Connecting $db->databaseType...</h1>";
104        $access = 'd:\inetpub\wwwroot\php\NWIND.MDB';
105        $dsn = "nwind";
106        $dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=$access;Uid=Admin;Pwd=;";
107       
108        //$dsn =  'Provider=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=' . $access . ';';
109        if ($db->PConnect($dsn, "", "", ""))
110                testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
111        else print "ERROR: Access test requires a Windows ODBC DSN=nwind, Access driver";
112       
113}
114
115if (!empty($testaccess) && !empty($testado)) { // ADO ACCESS
116
117        $db = &ADONewConnection("ado_access");
118        print "<h1>Connecting $db->databaseType...</h1>";
119       
120        $access = 'd:\inetpub\wwwroot\php\NWIND.MDB';
121        $myDSN =  'PROVIDER=Microsoft.Jet.OLEDB.4.0;'
122                . 'DATA SOURCE=' . $access . ';';
123                //. 'USER ID=;PASSWORD=;';
124       
125        if ($db->PConnect($myDSN, "", "", "")) {
126                print "ADO version=".$db->_connectionID->version."<br>";
127                testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
128        } else print "ERROR: Access test requires a Access database $access".'<BR>'.$db->ErrorMsg();
129       
130}
131
132if (!empty($testvfp)) { // ODBC
133        $db = &ADONewConnection('vfp');
134        print "<h1>Connecting $db->databaseType...</h1>";flush();
135
136        if ( $db->PConnect("vfp-adoxyz")) {
137                testdb($db,"create table d:\\inetpub\\adodb\\ADOXYZ (id int, firstname char(24), lastname char(24),created date)");
138         } else print "ERROR: Visual FoxPro test requires a Windows ODBC DSN=vfp-adoxyz, VFP driver";
139       
140}
141
142
143// REQUIRES MySQL server at localhost with database 'test'
144if (!empty($testmysql)) { // MYSQL
145
146
147        if (PHP_VERSION >= 5 || $HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost';
148        else $server = "mangrove";
149        $user = 'root'; $password = ''; $database = 'northwind';
150        $db = &ADONewConnection("mysql://$user:$password@$server/$database?persist");
151        print "<h1>Connecting $db->databaseType...</h1>";
152       
153        if (true || $db->PConnect($server, "root", "", "northwind")) {
154                //$db->debug=1;$db->Execute('drop table ADOXYZ');
155                testdb($db,
156                "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)");
157        } else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg();
158}
159
160// REQUIRES MySQL server at localhost with database 'test'
161if (!empty($testmysqli)) { // MYSQL
162
163        $db = &ADONewConnection('mysqli');
164        print "<h1>Connecting $db->databaseType...</h1>";
165        if (PHP_VERSION >= 5 || $HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost';
166        else $server = "mangrove";
167        if ($db->PConnect($server, "root", "", "northwind")) {
168                //$db->debug=1;$db->Execute('drop table ADOXYZ');
169                testdb($db,
170                "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)");
171        } else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg();
172}
173
174
175// REQUIRES MySQL server at localhost with database 'test'
176if (!empty($testmysqlodbc)) { // MYSQL
177       
178        $db = &ADONewConnection('odbc');
179        $db->hasTransactions = false;
180        print "<h1>Connecting $db->databaseType...</h1>";
181        if ($HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost';
182        else $server = "mangrove";
183        if ($db->PConnect('mysql', "root", ""))
184                testdb($db,
185                "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) type=innodb");
186        else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg();
187}
188
189if (!empty($testproxy)){
190        $db = &ADONewConnection('proxy');
191        print "<h1>Connecting $db->databaseType...</h1>";
192        if ($HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost';
193
194        if ($db->PConnect('http://localhost/php/phplens/adodb/server.php'))
195                testdb($db,
196                "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) type=innodb");
197        else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg();
198
199}
200
201ADOLoadCode('oci805');
202ADOLoadCode("oci8po");
203if (!empty($testoracle)) {
204        $dsn = "oci8po://scott:natsoft@panther?persist";
205        $db = ADONewConnection($dsn);
206        print "<h1>Connecting $db->databaseType...</h1>";
207        if (true || $db->Connect('', "scott", "natsoft",''))
208                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();
210
211}
212ADOLoadCode("oracle"); // no longer supported
213if (false && !empty($testoracle)) {
214       
215        $db = ADONewConnection();
216        print "<h1>Connecting $db->databaseType...</h1>";
217        if ($db->PConnect("", "scott", "tiger", "natsoft.domain"))
218                testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)");
219        else print "ERROR: Oracle test requires an Oracle server setup with scott/tiger".'<BR>'.$db->ErrorMsg();
220
221}
222
223ADOLoadCode("db2"); // no longer supported
224if (!empty($testdb2)) {
225       
226        $db = ADONewConnection();
227        print "<h1>Connecting $db->databaseType...</h1>";
228        if ($db->Connect("db2_sample", "root", "natsoft", ""))
229                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
232}
233
234
235ADOLoadCode('odbc_mssql');
236if (!empty($testmssql)) { // MS SQL Server via ODBC
237        $db = ADONewConnection();
238       
239        print "<h1>Connecting $db->databaseType...</h1>";
240       
241        $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=localhost;Database=northwind;";
242       
243        if ($db->PConnect($dsn, "adodb", "natsoft", ""))  {
244                testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
245        }
246        else print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN setup";
247
248}
249
250ADOLoadCode("ado_mssql");
251
252if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC -- DSN-less
253       
254        $db = &ADONewConnection("ado_mssql");
255        //$db->debug=1;
256        print "<h1>Connecting DSN-less $db->databaseType...</h1>";
257       
258        $myDSN="PROVIDER=MSDASQL;DRIVER={SQL Server};"
259                . "SERVER=tigress;DATABASE=NorthWind;UID=adodb;PWD=natsoft;Trusted_Connection=No"  ;
260
261               
262        if ($db->PConnect($myDSN, "", "", ""))
263                testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
264        else print "ERROR: MSSQL test 2 requires MS SQL 7";
265       
266}
267
268
269ADOLoadCode("mssqlpo");
270if (!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
285if (!empty($testmssql) && !empty($testado)) { // ADO ACCESS MSSQL with OLEDB provider
286
287        $db = &ADONewConnection("ado_mssql");
288        print "<h1>Connecting DSN-less OLEDB Provider $db->databaseType...</h1>";
289        //$db->debug=1;
290        $myDSN="SERVER=tigress;DATABASE=northwind;Trusted_Connection=yes";
291        if ($db->PConnect($myDSN, "adodb", "natsoft", 'SQLOLEDB'))
292                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'";
294
295}
296
297
298print "<h3>Tests Completed</h3>";
299
300?>
Note: See TracBrowser for help on using the repository browser.