moving server source files to server folder
[csql.git] / test / phptests / primarytest.php
blob845d08551a9f2602eb0800ebb0bb5a4851aa55bf
1 <html>
2 <body>
3 /* Creating table with Primary key 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 , f2 int, primary key(f1));");
14 $res = odbc_execute($sth);
15 if (!$res)
17 echo "Error in Creation";
18 exit(2);
20 echo "Table Created";
22 $sth = odbc_prepare($conn, "insert into t1 values (10, 20);");
23 $res = odbc_execute($sth);
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 (10, 30);");
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 odbc_result_all($rs);
43 $sth=odbc_prepare($conn,"DROP TABLE t1;");
44 $res = odbc_execute($sth);
45 if (!$res)
47 echo "\nError in Drop Table";
48 exit(5);
50 echo "\nTable Dropped\nTest Passed\n";
51 odbc_close($conn);
53 </body>
54 </html>