adding test scripts
[csql.git] / test / phptests / rowinfo.php
blob4b5ac16fb6ea393f132d1646f79f07c131daddba
1 <html>
2 <body>
3 /* Testing odbc_num_rows() for display number of rows */
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 $sth = odbc_prepare($conn,"INSERT INTO t1 VALUES(20,'Twenty',2,10000001,10.01,10000001.000001,'2001-1-1','2001-11-30 01:01:01');");
23 $res = odbc_execute($sth);
24 if (!$res)
26 echo "Error in Creation";
27 exit(3);
29 echo "Record Inserted\n";
31 $sth = odbc_prepare($conn,"INSERT INTO t1 VALUES(30,'Thirty',3,20000002,20.02,20000002.000002,'2002-2-2','2002-22-30 02:02:02');");
32 $res = odbc_execute($sth);
33 if (!$res)
35 echo "Error in Creation";
36 exit(4);
38 echo "Record Inserted\n";
40 $sql = 'SELECT * FROM t1;';
41 $result = odbc_exec($conn, $sql);
42 echo "Number of rows = ";
43 $a=odbc_num_rows($result);
44 if (!$a)
46 odbc_exec($conn,"DROP TABLE t1;");
47 exit(5);
49 echo $a;
51 $sql = "SELECT f3,f5,f7 FROM t1";
52 $result = odbc_exec($conn, $sql);
53 echo "\n<table> \n";
54 while (odbc_fetch_row($result))
56 $a=preg_replace('/[\x00-\x09\x0B-\x19\x7F]/', '',odbc_result($result,1));
57 $b=preg_replace('/[\x00-\x09\x0B-\x19\x7F]/', '',odbc_result($result,2));
58 $c=preg_replace('/[\x00-\x09\x0B-\x19\x7F]/', '',odbc_result($result,3));
59 echo "<tr>";
60 echo "<td>$a</td><td>$b</td><td>$c</td></tr>";
61 echo "\n";
63 echo "</table>";
64 $sth=odbc_prepare($conn,"DROP TABLE t1;");
65 $res = odbc_execute($sth);
66 if (!$res)
68 echo "\nError in Drop Table";
69 exit(6);
71 echo "\nTable Dropped \nTest Passed";
72 odbc_close($conn);
75 </body>
76 </html>