php - MySQLi multi_query results for later use -


i using mysqli multi_query work several select statemets @ time. know how handle results, able use them later in code.

example:

<?php  //connection stuff  $query = "select name, surname database1;"; $query.= "select car, year, type database2 carid='1';"; $query.= "select product, price database3;";  if ($mysqli->multi_query($query)) {  if($result = $mysqli->store_result()) {  while($row = $result->fetch_row()) {  -->   here?  }  }  }  ?>  <html>  <div id='persona'> <?php foreach() { --> print name + surname } ?> </div>  <div id='cars'> <?php foreach() { --> print car + year + type } ?> </div>  <div id='product'> <?php foreach() { --> print product + price } ?> </div>  </html> 

one more thing, prepared statements not possible when using multiple_query, right?

there no benefit in putting unrelated queries in 1 multi query call. in fact, risk of getting hit sql injection way bigger! regular query function allow 1 query per call, impossible inject select statement, ending prematurely , add delete.

with multi_query, possible.

additionally, have fetch , end each query, , it's gone. you cannot change between query results @ will, have fetched in order issued.

the better way execute independent simple queries. allow use prepared statements well, , long not getting huge amounts of data back, use same amount of memory , not annoy anyone.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -