adding test scripts
[csql.git] / test / phptests / columninfo4.php
blob55c25129e4bc0655259313d37397c617a17bfad4
1 <html>
2 <body>
3 /*Testing odbc_field_len for find out column length */
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),primary key(f1));");
13 $sth = odbc_prepare($conn,"CREATE TABLE t1(f1 INT, f2 CHAR(20),f3 SMALLINT,f4 BIGINT,f5 FLOAT, f6 DOUBLE,f7 DATE, f8 TIMESTAMP );");
14 $res = odbc_execute($sth);
15 if (!$res)
17 echo "Error in Creation";
18 exit(2);
20 echo "Table Created\n";
22 $sql = "SELECT * FROM t1";
23 $result = odbc_exec($conn, $sql);
25 echo "\nTesting odbc_field_len() for find out column length \n";
26 for ($col=1; $col<=odbc_num_fields($result); $col++)
28 $rs = odbc_field_len($result, $col);
29 if (!$rs)
31 exit(2);
33 printf("Column %d has length(Field Pression) is %d\n" ,$col, odbc_field_len($result, $col));
36 $sth=odbc_prepare($conn,"DROP TABLE t1;");
37 $res = odbc_execute($sth);
38 if (!$res)
39 {exit("\nError in Drop Table");}
40 echo "\nTable Dropped \nTest Passed";
41 odbc_close($conn);
44 </body>
45 </html>