code reorg for Transactionw!
[csql.git] / test / phptests / uniqueindex.php
blob19bdd76cb508b704af859df996bf6bf2b3e1a0ec
1 <html>
2 <body>
3 /*Creating table with 3 INT fields, Create unique index on single field.
4 Create possible composite unique indexes in different Combinations
5 */
6 <?php
7 $conn=odbc_connect('mycsql','root','manager');
8 if (!$conn)
10 echo "Connection Failed";
11 exit(1);
14 $sth = odbc_prepare($conn,"create table t1 (f1 int ,f2 int,f3 int );");
15 $res = odbc_execute($sth);
16 if (!$res)
18 echo "Error in Table Creation";
19 exit(2);
21 echo "Table Created";
23 $sth = odbc_prepare($conn, "create index idx1 on t1(f1) unique;");
24 $res = odbc_execute($sth);
25 if (!$res)
27 echo "Error in index";
28 exit(3);
30 echo "\ncreate index idx1 on t1(f1) unique;";
31 echo "\nIndex created\n";
33 $sth = odbc_prepare($conn, "create index idx2 on t1(f1,f2) unique;");
34 $res = odbc_execute($sth);
35 if (!$res)
37 echo "\ncreate index idx1 on t1(f1) unique;";
38 exit(4);
40 echo "\ncreate index idx2 on t1(f1,f2) unique;";
41 echo "\nComposite key Index created\n";
43 $sth = odbc_prepare($conn, "create index idx5 on t1(f1,f2,f3) unique;");
44 $res = odbc_execute($sth);
45 if (!$res)
47 echo "\nError in index creation;";
48 exit(5);
50 echo "\ncreate index idx5 on t1(f1,f2,f3) unique;";
51 echo "\nComposite key Index created\n";
53 $res = odbc_exec($conn, "DROP TABLE t1;");
54 if (!$res)
56 echo "\ncError in drop table;";
57 exit(6);
59 echo "\nTable Dropped\nTest Passed";
60 odbc_close($conn);
63 </body>
64 </html>