testing commit
[openemr.git] / library / adodb / tests / client.php
blob7bf145e7fa30f0e0e72c9f8712bc9898a9cee1ee
1 <html>
2 <body bgcolor=white>
3 <?php
4 /**
5 * V4.50 6 July 2004 (c) 2001-2002 John Lim (jlim#natsoft.com). All rights reserved.
6 * Released under both BSD license and Lesser GPL library license.
7 Whenever there is any discrepancy between the two licenses,
8 the BSD license will take precedence.
9 *
10 * set tabs to 8
13 // documentation on usage is at http://php.weblogs.com/adodb_csv
15 echo PHP_VERSION,'<br>';
16 var_dump(parse_url('odbc_mssql://userserver/'));
17 die();
19 include('../adodb.inc.php');
20 include('../tohtml.inc.php');
22 function send2server($url,$sql)
24 $url .= '?sql='.urlencode($sql);
25 print "<p>$url</p>";
26 $rs = csv2rs($url,$err);
27 if ($err) print $err;
28 return $rs;
31 function print_pre($s)
33 print "<pre>";print_r($s);print "</pre>";
37 $serverURL = 'http://localhost/php/phplens/adodb/server.php';
38 $testhttp = false;
40 $sql1 = "insertz into products (productname) values ('testprod 1')";
41 $sql2 = "insert into products (productname) values ('testprod 1')";
42 $sql3 = "insert into products (productname) values ('testprod 2')";
43 $sql4 = "delete from products where productid>80";
44 $sql5 = 'select * from products';
46 if ($testhttp) {
47 print "<a href=#c>Client Driver Tests</a><p>";
48 print "<h3>Test Error</h3>";
49 $rs = send2server($serverURL,$sql1);
50 print_pre($rs);
51 print "<hr />";
53 print "<h3>Test Insert</h3>";
55 $rs = send2server($serverURL,$sql2);
56 print_pre($rs);
57 print "<hr />";
59 print "<h3>Test Insert2</h3>";
61 $rs = send2server($serverURL,$sql3);
62 print_pre($rs);
63 print "<hr />";
65 print "<h3>Test Delete</h3>";
67 $rs = send2server($serverURL,$sql4);
68 print_pre($rs);
69 print "<hr />";
72 print "<h3>Test Select</h3>";
73 $rs = send2server($serverURL,$sql5);
74 if ($rs) rs2html($rs);
76 print "<hr />";
80 print "<a name=c><h1>CLIENT Driver Tests</h1>";
81 $conn = ADONewConnection('csv');
82 $conn->Connect($serverURL);
83 $conn->debug = true;
85 print "<h3>Bad SQL</h3>";
87 $rs = $conn->Execute($sql1);
89 print "<h3>Insert SQL 1</h3>";
90 $rs = $conn->Execute($sql2);
92 print "<h3>Insert SQL 2</h3>";
93 $rs = $conn->Execute($sql3);
95 print "<h3>Select SQL</h3>";
96 $rs = $conn->Execute($sql5);
97 if ($rs) rs2html($rs);
99 print "<h3>Delete SQL</h3>";
100 $rs = $conn->Execute($sql4);
102 print "<h3>Select SQL</h3>";
103 $rs = $conn->Execute($sql5);
104 if ($rs) rs2html($rs);
107 /* EXPECTED RESULTS FOR HTTP TEST:
109 Test Insert
110 http://localhost/php/adodb/server.php?sql=insert+into+products+%28productname%29+values+%28%27testprod%27%29
112 adorecordset Object
114 [dataProvider] => native
115 [fields] =>
116 [blobSize] => 64
117 [canSeek] =>
118 [EOF] => 1
119 [emptyTimeStamp] =>
120 [emptyDate] =>
121 [debug] =>
122 [timeToLive] => 0
123 [bind] =>
124 [_numOfRows] => -1
125 [_numOfFields] => 0
126 [_queryID] => 1
127 [_currentRow] => -1
128 [_closed] =>
129 [_inited] =>
130 [sql] => insert into products (productname) values ('testprod')
131 [affectedrows] => 1
132 [insertid] => 81
136 --------------------------------------------------------------------------------
138 Test Insert2
139 http://localhost/php/adodb/server.php?sql=insert+into+products+%28productname%29+values+%28%27testprod%27%29
141 adorecordset Object
143 [dataProvider] => native
144 [fields] =>
145 [blobSize] => 64
146 [canSeek] =>
147 [EOF] => 1
148 [emptyTimeStamp] =>
149 [emptyDate] =>
150 [debug] =>
151 [timeToLive] => 0
152 [bind] =>
153 [_numOfRows] => -1
154 [_numOfFields] => 0
155 [_queryID] => 1
156 [_currentRow] => -1
157 [_closed] =>
158 [_inited] =>
159 [sql] => insert into products (productname) values ('testprod')
160 [affectedrows] => 1
161 [insertid] => 82
165 --------------------------------------------------------------------------------
167 Test Delete
168 http://localhost/php/adodb/server.php?sql=delete+from+products+where+productid%3E80
170 adorecordset Object
172 [dataProvider] => native
173 [fields] =>
174 [blobSize] => 64
175 [canSeek] =>
176 [EOF] => 1
177 [emptyTimeStamp] =>
178 [emptyDate] =>
179 [debug] =>
180 [timeToLive] => 0
181 [bind] =>
182 [_numOfRows] => -1
183 [_numOfFields] => 0
184 [_queryID] => 1
185 [_currentRow] => -1
186 [_closed] =>
187 [_inited] =>
188 [sql] => delete from products where productid>80
189 [affectedrows] => 2
190 [insertid] => 0
193 [more stuff deleted]