windows porting changes
[csql.git] / test / phptests / datatype.php
bloba1bd870789c5126337467530dc595c7d556de09d
1 <html>
2 <body>
3 /*Create table and with all types of datatypes,Insert one valid record It Should be Passed */
5 <?php
6 $conn=odbc_connect('mycsql','root','manager');
7 if (!$conn)
9 echo "Connection Failed: " . $conn;
10 exit(1);
13 $sth = odbc_prepare($conn,"CREATE TABLE t1(f1 INT,f2 INT);");
14 $res = odbc_execute($sth);
15 if (!$res)
17 echo "Error in Creation";
18 exit(2);
20 $sth = odbc_prepare($conn, "INSERT INTO t1 VALUES(12,120);");
21 $res = odbc_execute($sth);
22 if (!$res)
24 echo "Error in Insertion";
25 exit(3);
27 $sth = 'select * from t1;';
28 $rs = odbc_exec($conn, $sth);
29 if (!$rs)
31 echo "Error in SQL-2";
32 ecit(4);
34 odbc_result_all($rs, 'border = 5');
35 odbc_exec($conn,"DROP TABLE t1");
38 $sth = odbc_prepare($conn,"CREATE TABLE t1(f1 INT);");
39 $res = odbc_execute($sth);
40 if (!$res)
42 echo "Error in Creation";
43 exit(5);
45 $sth = odbc_prepare($conn, "INSERT INTO t1 VALUES(12);");
46 $res = odbc_execute($sth);
47 if (!$res)
49 echo "Error in Insertion";
50 exit(6);
52 $sth = 'select * from t1;';
53 $rs = odbc_exec($conn, $sth);
54 if (!$rs)
56 echo "Error in SQL-2";
57 exit(7);
59 odbc_result_all($rs, 'border = 5');
60 odbc_exec($conn,"DROP TABLE t1");
62 $sth = odbc_prepare($conn,"CREATE TABLE t1(f1 char(20));");
63 $res = odbc_execute($sth);
64 if (!$res)
66 echo "Error in Creation";
67 exit(8);
69 $sth = odbc_prepare($conn, "INSERT INTO t1 VALUES('TWELVE');");
70 $res = odbc_execute($sth);
71 if (!$res)
73 echo "Error in Insertion";
74 exit(9);
76 $sth = 'select * from t1;';
77 $rs = odbc_exec($conn, $sth);
78 if (!$rs)
80 echo "Error in SQL-2";
81 exit(10);
83 odbc_result_all($rs, 'border = 5');
84 odbc_exec($conn,"DROP TABLE t1");
86 $sth = odbc_prepare($conn,"CREATE TABLE t1(f1 SMALLINT);");
87 $res = odbc_execute($sth);
88 if (!$res)
90 echo "Error in Creation";
91 exit(11);
93 $sth = odbc_prepare($conn, "INSERT INTO t1 VALUES(1);");
94 $res = odbc_execute($sth);
95 if (!$res)
97 echo "Error in Insertion";
98 exit(12);
100 $sth = 'select * from t1;';
101 $rs = odbc_exec($conn, $sth);
102 if (!$rs)
104 echo "Error in SQL-2";
105 exit(13);
107 odbc_result_all($rs, 'border = 5');
108 odbc_exec($conn,"DROP TABLE t1");
110 $sth = odbc_prepare($conn,"CREATE TABLE t1(f1 BIGINT);");
111 $res = odbc_execute($sth);
112 if (!$res)
114 echo "Error in Creation";
115 exit(14);
117 $sth = odbc_prepare($conn, "INSERT INTO t1 VALUES(10000001);");
118 $res = odbc_execute($sth);
119 if (!$res)
121 echo "Error in Insertion";
122 exit(15);
124 $sth = 'select * from t1;';
125 $rs = odbc_exec($conn, $sth);
126 if (!$rs)
128 echo "Error in SQL-2";
129 exit(16);
131 odbc_result_all($rs, 'border = 5');
132 odbc_exec($conn,"DROP TABLE t1");
134 $sth = odbc_prepare($conn,"CREATE TABLE t1(f1 FLOAT);");
135 $res = odbc_execute($sth);
136 if (!$res)
138 echo "Error in Creation";
139 exit(17);
141 $sth = odbc_prepare($conn, "INSERT INTO t1 VALUES(10.01);");
142 $res = odbc_execute($sth);
143 if (!$res)
145 echo "Error in Insertion";
146 exit(18);
148 $sth = 'select * from t1;';
149 $rs = odbc_exec($conn, $sth);
150 if (!$rs)
152 echo "Error in SQL-2";
153 exit(19);
155 odbc_result_all($rs, 'border = 5');
156 odbc_exec($conn,"DROP TABLE t1");
158 $sth = odbc_prepare($conn,"CREATE TABLE t1(f1 DOUBLE);");
159 $res = odbc_execute($sth);
160 if (!$res)
162 echo "Error in Creation";
163 exit(20);
165 $sth = odbc_prepare($conn, "INSERT INTO t1 VALUES(100001.100001);");
166 $res = odbc_execute($sth);
167 if (!$res)
169 echo "Error in Insertion";
170 exit(21);
172 $sth = 'select * from t1;';
173 $rs = odbc_exec($conn, $sth);
174 if (!$rs)
176 echo "Error in SQL-2";
177 exit(22);
179 odbc_result_all($rs, 'border = 5');
180 odbc_exec($conn,"DROP TABLE t1");
182 $sth = odbc_prepare($conn,"CREATE TABLE t1(f1 DATE);");
183 $res = odbc_execute($sth);
184 if (!$res)
186 echo "Error in Creation";
187 exit(23);
189 $sth = odbc_prepare($conn, "INSERT INTO t1 VALUES('2001-1-1');");
190 $res = odbc_execute($sth);
191 if (!$res)
193 echo "Error in Insertion" ;
194 exit(24);
196 $sth = 'select * from t1;';
197 $rs = odbc_exec($conn, $sth);
198 if (!$rs)
200 echo "Error in SQL-2";
201 exit(25);
203 odbc_result_all($rs, 'border = 5');
204 odbc_exec($conn,"DROP TABLE t1");
206 $sth = odbc_prepare($conn,"CREATE TABLE t1(f1 TIMESTAMP);");
207 $res = odbc_execute($sth);
208 if (!$res)
210 echo "Error in Creation";
211 exit(26);
213 $sth = odbc_prepare($conn, "INSERT INTO t1 VALUES('2001-11-30 01:01:01');");
214 $res = odbc_execute($sth);
215 if (!$res)
217 echo "Error in Insertion";
218 exit(27);
220 $sth = 'select * from t1;';
221 $rs = odbc_exec($conn, $sth);
222 if (!$rs)
224 echo "Error in SQL-2";
225 exit(28);
227 odbc_result_all($rs, 'border = 5');
228 $res=odbc_exec($conn,"DROP TABLE t1");
229 if (!$res)
231 echo "Error in Drop Table";
232 exit(29);
234 echo "\nTable Dropped\nTest Passed";
235 odbc_close($conn);
238 </body>
239 </html>