Hi. I've found a letter in mysql users mailing list in which user tells us that mysqli doesn't properly works with stored procedurs. when we use select statment without INTO param. Here it is: ###################################################3
Hi.
I am using MySQL 5.0.1 (snapshot) and PHP 5.0.2 with mysqli interface (latest snapshot) under Linux (SUSE 9.1).
I would like to call a SP using PHP 5, and I want to get back the SELECT results.
This is my SP:
CREATE PROCEDURE `test`() BEGIN SELECT * FROM t1; END
From the comments in http://bugs.mysql.com/bug.php?id=2273 I
understand I have to use mysqli_multi_query if I want to get rowsets from a SP. Fine:
$ok = $mysqli->multi_query("CALL test()");
if($ok) {
echo "<p>OK</p>\n";
do {
echo "<p>result</p>\n";
$result = $mysqli->store_result();
if($result) {
show_table($result); // shows result details
$result->close();
}
} while($mysqli->next_result());
}I don't get any results, $ok is FALSE.
If I instead use the following code, everything works fine, I receive both rowsets. So, the PHP code above seems to be ok as long as I don't call a SP.
$ok = $mysqli->multi_query("SELECT * FROM t1; SELECT * FROM t1");Any ideas? Error in MySQL or in PHP?
Thank you,
Michael Kofler
http://www.kofler.cc/ ############################################################3
I've checked this information,and found that code really doesn't work when i used
$mysqli=mysqli_connect('localhost', 'root','s','test',3807,"/tmp/mysql.sock.gleb.3")
to connect to server.
But when i change that to
$mysqli=mysqli_init();
$mysqli->real_connect('localhost', 'root','s','test',3807,"/tmp/mysql.sock.gleb.3");
Every thing works fine.
May be it is a php bug.
My code:
<?
$mysqli=mysqli_init();
$mysqli->real_connect('localhost', 'root','s','test',3807,"/tmp/mysql.sock.gleb.3");
//$mysqli=mysqli_connect('localhost', 'root','s','test',3807,"/tmp/mysql.sock.gleb.3");
$ok = $mysqli->multi_query("call test();");
echo $mysqli->info;
//$ok = $mysqli->multi_query("select * from t1;");
//if($ok) {
//echo "<p>OK</p>\n";
//echo $mysqli->mysqli_errno()."\n";
//echo $mysqli->mysqli_sqlstate."\n";
do {
echo "<p>result</p>\n";
$result = $mysqli->store_result();
if($result) {
while ($line = mysqli_fetch_array($result, MYSQL_ASSOC)) { echo "\t<tr>\n"; foreach ($line as $col_value) { echo "\t\t<td>$col_value</td>\n"; } echo "\t</tr>\n"; } $result->close(); } } while($mysqli->next_result()); //} ?>
-- Gleb Paharenko
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
