1 | <html> |
---|
2 | <body bgcolor=white> |
---|
3 | <?php |
---|
4 | /** |
---|
5 | * V4.50 6 July 2004 (c) 2001-2002 John Lim (jlim@natsoft.com.my). 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 |
---|
11 | */ |
---|
12 | |
---|
13 | // documentation on usage is at http://php.weblogs.com/adodb_csv |
---|
14 | |
---|
15 | include('../adodb.inc.php'); |
---|
16 | include('../tohtml.inc.php'); |
---|
17 | |
---|
18 | function &send2server($url,$sql) |
---|
19 | { |
---|
20 | $url .= '?sql='.urlencode($sql); |
---|
21 | print "<p>$url</p>"; |
---|
22 | $rs = csv2rs($url,$err); |
---|
23 | if ($err) print $err; |
---|
24 | return $rs; |
---|
25 | } |
---|
26 | |
---|
27 | function print_pre($s) |
---|
28 | { |
---|
29 | print "<pre>";print_r($s);print "</pre>"; |
---|
30 | } |
---|
31 | |
---|
32 | |
---|
33 | $serverURL = 'http://localhost/php/phplens/adodb/server.php'; |
---|
34 | $testhttp = false; |
---|
35 | |
---|
36 | $sql1 = "insertz into products (productname) values ('testprod 1')"; |
---|
37 | $sql2 = "insert into products (productname) values ('testprod 1')"; |
---|
38 | $sql3 = "insert into products (productname) values ('testprod 2')"; |
---|
39 | $sql4 = "delete from products where productid>80"; |
---|
40 | $sql5 = 'select * from products'; |
---|
41 | |
---|
42 | if ($testhttp) { |
---|
43 | print "<a href=#c>Client Driver Tests</a><p>"; |
---|
44 | print "<h3>Test Error</h3>"; |
---|
45 | $rs = send2server($serverURL,$sql1); |
---|
46 | print_pre($rs); |
---|
47 | print "<hr>"; |
---|
48 | |
---|
49 | print "<h3>Test Insert</h3>"; |
---|
50 | |
---|
51 | $rs = send2server($serverURL,$sql2); |
---|
52 | print_pre($rs); |
---|
53 | print "<hr>"; |
---|
54 | |
---|
55 | print "<h3>Test Insert2</h3>"; |
---|
56 | |
---|
57 | $rs = send2server($serverURL,$sql3); |
---|
58 | print_pre($rs); |
---|
59 | print "<hr>"; |
---|
60 | |
---|
61 | print "<h3>Test Delete</h3>"; |
---|
62 | |
---|
63 | $rs = send2server($serverURL,$sql4); |
---|
64 | print_pre($rs); |
---|
65 | print "<hr>"; |
---|
66 | |
---|
67 | |
---|
68 | print "<h3>Test Select</h3>"; |
---|
69 | $rs = send2server($serverURL,$sql5); |
---|
70 | if ($rs) rs2html($rs); |
---|
71 | |
---|
72 | print "<hr>"; |
---|
73 | } |
---|
74 | |
---|
75 | |
---|
76 | print "<a name=c><h1>CLIENT Driver Tests</h1>"; |
---|
77 | $conn = ADONewConnection('csv'); |
---|
78 | $conn->Connect($serverURL); |
---|
79 | $conn->debug = true; |
---|
80 | |
---|
81 | print "<h3>Bad SQL</h3>"; |
---|
82 | |
---|
83 | $rs = $conn->Execute($sql1); |
---|
84 | |
---|
85 | print "<h3>Insert SQL 1</h3>"; |
---|
86 | $rs = $conn->Execute($sql2); |
---|
87 | |
---|
88 | print "<h3>Insert SQL 2</h3>"; |
---|
89 | $rs = $conn->Execute($sql3); |
---|
90 | |
---|
91 | print "<h3>Select SQL</h3>"; |
---|
92 | $rs = $conn->Execute($sql5); |
---|
93 | if ($rs) rs2html($rs); |
---|
94 | |
---|
95 | print "<h3>Delete SQL</h3>"; |
---|
96 | $rs = $conn->Execute($sql4); |
---|
97 | |
---|
98 | print "<h3>Select SQL</h3>"; |
---|
99 | $rs = $conn->Execute($sql5); |
---|
100 | if ($rs) rs2html($rs); |
---|
101 | |
---|
102 | |
---|
103 | /* EXPECTED RESULTS FOR HTTP TEST: |
---|
104 | |
---|
105 | Test Insert |
---|
106 | http://localhost/php/adodb/server.php?sql=insert+into+products+%28productname%29+values+%28%27testprod%27%29 |
---|
107 | |
---|
108 | adorecordset Object |
---|
109 | ( |
---|
110 | [dataProvider] => native |
---|
111 | [fields] => |
---|
112 | [blobSize] => 64 |
---|
113 | [canSeek] => |
---|
114 | [EOF] => 1 |
---|
115 | [emptyTimeStamp] => |
---|
116 | [emptyDate] => |
---|
117 | [debug] => |
---|
118 | [timeToLive] => 0 |
---|
119 | [bind] => |
---|
120 | [_numOfRows] => -1 |
---|
121 | [_numOfFields] => 0 |
---|
122 | [_queryID] => 1 |
---|
123 | [_currentRow] => -1 |
---|
124 | [_closed] => |
---|
125 | [_inited] => |
---|
126 | [sql] => insert into products (productname) values ('testprod') |
---|
127 | [affectedrows] => 1 |
---|
128 | [insertid] => 81 |
---|
129 | ) |
---|
130 | |
---|
131 | |
---|
132 | -------------------------------------------------------------------------------- |
---|
133 | |
---|
134 | Test Insert2 |
---|
135 | http://localhost/php/adodb/server.php?sql=insert+into+products+%28productname%29+values+%28%27testprod%27%29 |
---|
136 | |
---|
137 | adorecordset Object |
---|
138 | ( |
---|
139 | [dataProvider] => native |
---|
140 | [fields] => |
---|
141 | [blobSize] => 64 |
---|
142 | [canSeek] => |
---|
143 | [EOF] => 1 |
---|
144 | [emptyTimeStamp] => |
---|
145 | [emptyDate] => |
---|
146 | [debug] => |
---|
147 | [timeToLive] => 0 |
---|
148 | [bind] => |
---|
149 | [_numOfRows] => -1 |
---|
150 | [_numOfFields] => 0 |
---|
151 | [_queryID] => 1 |
---|
152 | [_currentRow] => -1 |
---|
153 | [_closed] => |
---|
154 | [_inited] => |
---|
155 | [sql] => insert into products (productname) values ('testprod') |
---|
156 | [affectedrows] => 1 |
---|
157 | [insertid] => 82 |
---|
158 | ) |
---|
159 | |
---|
160 | |
---|
161 | -------------------------------------------------------------------------------- |
---|
162 | |
---|
163 | Test Delete |
---|
164 | http://localhost/php/adodb/server.php?sql=delete+from+products+where+productid%3E80 |
---|
165 | |
---|
166 | adorecordset Object |
---|
167 | ( |
---|
168 | [dataProvider] => native |
---|
169 | [fields] => |
---|
170 | [blobSize] => 64 |
---|
171 | [canSeek] => |
---|
172 | [EOF] => 1 |
---|
173 | [emptyTimeStamp] => |
---|
174 | [emptyDate] => |
---|
175 | [debug] => |
---|
176 | [timeToLive] => 0 |
---|
177 | [bind] => |
---|
178 | [_numOfRows] => -1 |
---|
179 | [_numOfFields] => 0 |
---|
180 | [_queryID] => 1 |
---|
181 | [_currentRow] => -1 |
---|
182 | [_closed] => |
---|
183 | [_inited] => |
---|
184 | [sql] => delete from products where productid>80 |
---|
185 | [affectedrows] => 2 |
---|
186 | [insertid] => 0 |
---|
187 | ) |
---|
188 | |
---|
189 | [more stuff deleted] |
---|
190 | . |
---|
191 | . |
---|
192 | . |
---|
193 | */ |
---|
194 | ?> |
---|