Error detection in multiple queries in MySQL using PHP -
I have a cover php class for mysqli, which can be found between multiple queries (mysqli :: multi_query) . It works but I am not getting any error when one of the questions fails. This is a simplified version of code:
$ queries = array ('select_from core_order_items', 'cell_actact * from core_read_atimes',); $ DbConnection = mysqli_connect ('localhost', 'ciala', 'arifisis', 'mydi'); $ DbConnection-> Set_charset ('UTF8'); $ DbConnection-> Multi_query (implode (';', $ queries)); $ I = =; Do {echo} query: "$ queries [$ i]" - "; $ Resultset = $ dbConnection-> Store_result (); If ($ resultset === incorrect & strlen ($ dbConnection-> False)> 0) {resonant "returned error for query" $ I. "& Lt; br & gt;"; } Else {echo "returned for query" $ I. "& Lt; br & gt;"; } $ I ++; } While ($ dbConnection-> next_salt ()); Mysqli_close ($ dbConnection);
Note that both SQL queries are OK first and the second is invalid. The result is:
query: select * from core_read_iites - returned for query 0
What happened to my second query? If I fix this, it shows, but when an error occurs, like it is not even in the array. How do I get error numbers / messages?
mysqli :: next_result if incorrect. This example
$ dbConnection - & gt; Multi_quirer ($ query); Do {$ dbConnection - & gt; Use_result () - & gt; Stop it (); The echo is "OK \ n"; } While ($ mysqli-> next_salt ()); If ($ mysqli- & gt; wrong) {echo "Stopped while getting results:" $ Mysqli-> Error; }
Comments
Post a Comment