3 /*Create table and test all DML Operation on the table */
5 $conn=odbc_connect('mycsql','root','manager');
8 echo "Connection Failed";
12 $sth = odbc_prepare($conn,"CREATE TABLE t1(f1 INT, f2 CHAR(20));");
13 $res = odbc_execute($sth);
16 echo "Error in Creation";
21 $sth = odbc_prepare($conn, "INSERT INTO t1(f1, f2) VALUES(12,'Twelve');");
22 $res = odbc_execute($sth);
25 echo "Error in Insertion";
28 echo "\nRecord Inserted";
30 $sth = 'select * from t1;';
31 $rs = odbc_exec($conn, $sth);
34 echo "Error in selection";
37 echo "\nselect executed\n";
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";
52 $sth = odbc_prepare($conn, "UPDATE t1 SET f2='TWELVE';");
53 $res = odbc_execute($sth);
56 echo "\nError in Updation\n";
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";
72 $sth = odbc_prepare($conn, "DELETE FROM t1;");
73 $res = odbc_execute($sth);
76 echo "\nError in Deletion\n";
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";
92 $sth=odbc_prepare($conn,"DROP TABLE t1;");
93 $res = odbc_execute($sth);
96 echo "\nError in Drop Table";
99 echo "\nTable Dropped \nTest Passed";