3

is there a maximum number of queries when run a multiquery using php?

  $conn = new mysqli($db_hostname, $db_username, $db_password);
    if (mysqli_connect_errno()) {
      exit('Connect failed: '. mysqli_connect_error());
    }  

   $sql = "CREATE TABLE IF NOT EXISTS......";
   $sql .= "CREATE TABLE IF NOT EXISTS......";
   $sql .= "CREATE TABLE IF NOT EXISTS......";
   $sql .= "INSERT ......";
   $sql .= "INSERT ......";
    <and so on>
    mysqli_autocommit($conn, false);
    mysqli_multi_query($conn, $sql);
    mysqli_rollback($conn); 
HaskellElephant
  • 9,819
  • 4
  • 38
  • 67
sadpcd201209
  • 33
  • 1
  • 7

1 Answers1

0

I don't now wheter the PHP function mysqli_multi_query is implemented by using the multiquery possibilitie s of the MySQL API or if this splits the statements on the PHP side.

But you could try raising net_buffer_length but and max_allowed_packet in your my.cnf. But I was under the impression that these were per statement buffers.

To be clear to people that stumble here, not out of curiosity as the OP did, but because they bumped into the maximum: There usually are other ways to do many INSERTs.

Community
  • 1
  • 1
Chris Wesseling
  • 6,226
  • 2
  • 36
  • 72
  • 1
    I know this thread is a bit old, but looking through the PHP source (5.6) mysqli_multi_query function calls mysql_real_query and does not buffer the query requests internally. – Blake A. Nichols Apr 08 '15 at 17:57