windows porting changes
[csql.git] / test / phptests / dml.php
blob521896378dd48d931164dbd585fb73acdc34befc
1 <html>
2 <body>
3 /*Create table and test all DML Operation on the table */
4 <?php
5 $conn=odbc_connect('mycsql','root','manager');
6 if (!$conn)
8 echo "Connection Failed";
9 exit(1);
12 $sth = odbc_prepare($conn,"CREATE TABLE t1(f1 INT, f2 CHAR(20));");
13 $res = odbc_execute($sth);
14 if (!$res)
16 echo "Error in Creation";
17 exit(2);
19 echo "Table Created";
21 $sth = odbc_prepare($conn, "INSERT INTO t1(f1, f2) VALUES(12,'Twelve');");
22 $res = odbc_execute($sth);
23 if (!$res)
25 echo "Error in Insertion";
26 exit(3);
28 echo "\nRecord Inserted";
30 $sth = 'select * from t1;';
31 $rs = odbc_exec($conn, $sth);
32 if (!$rs)
34 echo "Error in selection";
35 exit(4);
37 echo "\nselect executed\n";
39 echo "<table><tr>";
40 echo "<th>ROLL</th>";
41 echo "<th>NAME</th></tr>";
42 echo "\nfetch started\n";
43 while (odbc_fetch_row($rs))
45 $roll=preg_replace('/[\x00-\x09\x0B-\x19\x7F]/', '',odbc_result($rs, 1));
46 $name=preg_replace('/[\x00-\x09\x0B-\x19\x7F]/', '',odbc_result($rs, 2));
47 echo "<tr><td>$roll</td>";
48 echo "<td>$name</td></tr>\n";
50 echo "</table>";
52 $sth = odbc_prepare($conn, "UPDATE t1 SET f2='TWELVE';");
53 $res = odbc_execute($sth);
54 if (!$res)
56 echo "\nError in Updation\n";
57 exit(5);
59 echo "\nRecord Updated\n";
61 $sth = 'select * from t1;';
62 $rs = odbc_exec($conn, $sth);
63 while (odbc_fetch_row($rs))
65 $roll=preg_replace('/[\x00-\x09\x0B-\x19\x7F]/', '',odbc_result($rs, 1));
66 $name=preg_replace('/[\x00-\x09\x0B-\x19\x7F]/', '',odbc_result($rs, 2));
67 echo "<tr><td>$roll</td>";
68 echo "<td>$name</td></tr>\n";
70 echo "</table>";
72 $sth = odbc_prepare($conn, "DELETE FROM t1;");
73 $res = odbc_execute($sth);
74 if (!$res)
76 echo "\nError in Deletion\n";
77 exit(6);
79 echo "\nRecord Deleted\n";
81 $sth = 'select * from t1;';
82 $rs = odbc_exec($conn, $sth);
83 while (odbc_fetch_row($rs))
85 $roll=preg_replace('/[\x00-\x09\x0B-\x19\x7F]/', '',odbc_result($rs, 1));
86 $name=preg_replace('/[\x00-\x09\x0B-\x19\x7F]/', '',odbc_result($rs, 2));
87 echo "<tr><td>$roll</td>";
88 echo "<td>$name</td></tr>\n";
90 echo "</table>";
92 $sth=odbc_prepare($conn,"DROP TABLE t1;");
93 $res = odbc_execute($sth);
94 if (!$res)
96 echo "\nError in Drop Table";
97 exit(7);
99 echo "\nTable Dropped \nTest Passed";
100 odbc_close($conn);
102 </body>
103 </html>