4 /*Performance Test for all parameterised DML*/
6 $conn=odbc_connect('mycsql','root','');
8 {exit("Connection Failed: " . $conn);}
9 echo "Connection Passed\n";
11 $sth = odbc_prepare($conn,"CREATE TABLE t1 (f1 BIGINT, f2 char(196), primary key (f1));");
12 $res = odbc_execute($sth);
14 {exit("Error in Creation");}
15 echo "Table Created\n";
24 $q = "INSERT INTO t1(f1,f2) values(?,?);";
25 $b = "ABCDEFGHIJKLMNOPQRSTUVWXYZ9876543210";
26 $res = odbc_prepare ($conn, $q);
27 for ($i = 0; $i <100; $i++
)
29 $time_start = microtime();
31 odbc_execute($res, array($a, $b));
32 $time_end = microtime();
33 $time = $time_end - $time_start;
34 $timecount = $timecount +
$time ;
41 printf("\nInsert :%6d MIN :%4f MAX :%4f AVG :%4f microsec\n",$count,$min,$max,$timecount/$count);
43 $sth = 'SELECT * FROM t1;';
44 $rs = odbc_exec($conn, $sth);
46 {exit("Error in SQL-2");}
47 odbc_result_all($rs, 'border = 2');
56 $q = "SELECT * FROM t1 WHERE f1=?;";
57 $res = odbc_prepare ($conn, $q);
58 for ($i = 0; $i <100; $i++
)
60 $time_start = microtime();
62 $rs=odbc_execute($res, array($a));
66 echo "<th>NAME</th></tr>";
67 while (odbc_fetch_row($rs))
69 $roll=odbc_result($rs, 1);
70 $name=odbc_result($rs, 2);
71 echo "<tr><td>$roll</td>";
72 echo "<td>$name</td></tr>\n";
76 $time_end = microtime();
77 $time = $time_end - $time_start;
78 $timecount = $timecount +
$time ;
85 printf("\nSelect :%6d MIN :%4f MAX :%4f AVG :%4f microsec\n",$count,$min,$max,$timecount/$count);
94 $q = "update t1 set f2=? where f1=?;";
95 $res = odbc_prepare ($conn, $q);
96 for ($i = 0; $i <100; $i++
)
98 $time_start = microtime();
101 odbc_execute($res, array($a, $b));
102 $time_end = microtime();
103 $time = $time_end - $time_start;
104 $timecount = $timecount +
$time ;
111 printf("\nUpdate :%6d MIN :%4f MAX :%4f AVG :%4f microsec\n",$count,$min,$max,$timecount/$count);
113 $sth = 'SELECT * FROM t1;';
114 $rs = odbc_exec($conn, $sth);
116 {exit("Error in SQL-2");}
117 odbc_result_all($rs, 'border = 2');
126 $q = "DELETE FROM t1 WHERE f1=?;";
127 $res = odbc_prepare ($conn, $q);
128 for ($i = 0; $i <100; $i++
)
130 $time_start = microtime();
132 $rs = odbc_execute($res, array($a));
133 $time_end = microtime();
134 $time = $time_end - $time_start;
135 $timecount = $timecount +
$time ;
142 printf("\nDelete :%6d MIN :%4f MAX :%4f AVG :%4f microsec\n",$count,$min,$max,$timecount/$count);
144 $sth = 'SELECT * FROM t1;';
145 $rs = odbc_exec($conn, $sth);
147 {exit("Error in SQL-2");}
148 odbc_result_all($rs, 'border = 2');
150 $sth=odbc_prepare($conn,"DROP TABLE t1;");
151 $res = odbc_execute($sth);
153 {exit("\nError in Drop Table");}
154 echo "\nTable Dropped \nTest Passed";