php - mysqli_multi_query(); numerous submissions -
i have php script prepares 3 different sql submissions. sql valid of them. if swap order of if statements below, work. if $ratessql
first both 1) , 2) work. if either of other 2 first, 1) works.
the sql:
$sqlrates = " load xml local infile '/xx/yy/zz/example.xml' replace table rates rows identified '<row>'";
both $vixsql
, $aaasql
lot of replace into
statements. example:
replace aaa (date,value) values ('2016-01-29','4.05'); replace aaa (date,value) values ('2016-01-28','4.07');
the if statements:
1) successful submission below. $ratessql approximately 300 rows of data.
if (mysqli_multi_query($dbc, $ratessql)) { echo "<h3>rates load successful</h3><br>"; } else { echo "<h3>rates load error</h3><br>"; }
2) successful submission. ~8000 rows of data.
if (mysqli_multi_query($dbc, $vixsql)) { echo "<h3>vix load successful</h3><br>"; } else { echo "<h3>vix load error</h3><br>"; }
3) failed submission, ~8000 rows of data
if (mysqli_multi_query($dbc, $aaasql)) { echo "<h3>aaa load successful</h3><br>"; } else { echo "<h3>aaa load error</h3><br>"; }
the $ratessql
submission 300 rows of data whilst other 2 8000. data quantity causing me issues? suggestions getting round it?
combining queries per answer below allows me around this. still puzzling why separate queries failed. further info appreciated
combine query , use mysqli_multi_query
once
note:multiple queries should concatenated semicolon
$finalsqlquery = $sqlrates .';'.$vixsql.$aaasql; if(mysqli_multi_query($dbc,$finalsqlquery)){ //then can use mysqli_store_result() do{ if($result = mysqli_store_result($dbc)){ //note mysqli_store_result return buffer object , false on query error. print_r($result);/*display , check results of query if sure query doesn't have error check result of query*/ mysqli_free_result($result); } /* print divider */ if (mysqli_more_results($dbc)) { printf("-----------------\n"); } }while(mysqli_next_result($dbc)); $result = mysqli_store_result($dbc) }
Comments
Post a Comment