Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.5.0b5

Request #6418 mysqli_multi_query and procedures
Submitted: 2006-01-05 11:45 UTC
From: akg1 at fmu1 dot net Assigned: lsmith
Status: Closed Package: MDB2
PHP Version: 5.0.5 OS: Linux
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 28 - 4 = ?

 
 [2006-01-05 11:45 UTC] akg1 at fmu1 dot net
Description: ------------ Implementation to execute multiple stored procedures per one connection. Problem about using mysqli->query can be found here: http://bugs.php.net/bug.php?id=35203 http://bugs.php.net/bug.php?id=35333 So use of multi_query is needed. Test script: --------------- Sample script, when no results are needed: for($i=0; $i<3; $i++) { //asuming we have a valid mysqli object if (!$mysqli->multi_query("call someStoredProc(1)")) { printf("Error: %s\n", $mysqli->error); } else { do { if ($result = $mysqli->store_result()) { $result->close(); } } while ($mysqli->next_result()); } } This, however will cause an error: for($i=0; $i<3; $i++) { //asuming we have a valid mysqli object if (!$mysqli->multi_query("call someStoredProc(1)")) { printf("Error: %s\n", $mysqli->error); } else { $result = $mysqli->store_result()) $result->close(); } }

Comments

 [2006-01-12 17:26 UTC] lsmith
*sigh* .. the mysqli API is such utter crap .. Using a simple helloworld() sproc: http://gilfster.blogspot.com/2005/09/mysql-50-stored-procedures-getting.html Why do I even still get a bool false for $result ever? Shouldnt mysqli_next_result() prevent me from getting a bool false mysqli_store_result()? <?php $link = mysqli_connect("localhost", "root", "", "test"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $query = "SELECT CURRENT_USER();"; $query .= "SELECT VERSION();"; $query .= "CALL helloworld();"; for($j=0; $j<3;++$j) { $i=0; /* execute multi query */ if (mysqli_multi_query($link, $query)) { do { var_dump(++$i); /* store first result set */ if ($result = mysqli_store_result($link)) { while ($row = mysqli_fetch_row($result)) { printf("%s\n", $row[0]); } mysqli_free_result($result); } /* print divider */ if (mysqli_more_results($link)) { printf("-----------------<br>\n"); } } while (mysqli_next_result($link)); } var_dump($result); echo "<br>\n"; } /* close connection */ mysqli_close($link); ?>
 [2006-01-12 18:00 UTC] lsmith
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.