adding test scripts
[csql.git] / test / phptests / nulltest.php
blob7a94b798a873351495c75557eb25e59ed4ff2795
1 <html>
2 <body>
3 /* Creating table with not null constraint constraint on the int field
4 check basic INSERT, SELECT */
5 <?php
6 $conn=odbc_connect('mycsql','root','manager');
7 if (!$conn)
9 echo"Connection Failed";
10 exit(1);
13 $sth = odbc_prepare($conn,"create table t1 (f1 int not null, f2 int);");
14 $res = odbc_execute($sth);
15 if (!$res)
17 echo "Error in Creation";
18 exit(2);
20 echo "Table Created\n";
22 $res = odbc_exec($conn, "insert into t1 values (10, 20);");
23 echo $res ;
24 if (!$res)
26 echo "Error in Insertion";
27 exit(3);
29 echo "\nRecord Inserted\n";
31 $res = odbc_exec($conn,"insert into t1 values (null, 20);");
33 $sth = 'select * from t1;';
34 $rs = odbc_exec($conn, $sth);
35 if (!$rs)
37 echo "Error in SQL-2" ;
38 exit(4);
40 echo "\nselect executed\n";
41 echo "<table><tr>";
42 echo "<th>F1</th>";
43 echo "<th>F2</th></tr>";
44 echo "\nfetch started\n";
45 while (odbc_fetch_row($rs))
47 $roll=preg_replace('/[\x00-\x09\x0B-\x19\x7F]/', '',odbc_result($rs, 1));
48 $name=preg_replace('/[\x00-\x09\x0B-\x19\x7F]/', '',odbc_result($rs, 2));
49 echo "<tr><td>$roll</td>";
50 echo "<td>$name</td></tr>\n";
52 echo "</table>";
54 $sth=odbc_prepare($conn,"DROP TABLE t1");
55 $res = odbc_execute($sth);
56 if (!$res)
58 echo "\nError in Drop Table";
59 exit(5);
61 echo "\nTable Dropped\nTest Passed";
62 odbc_close($conn);
65 </body>
66 </html>