title: MySQLi : Inserting multiple rows with one prepared statement
body: <p>I made a script that creates a raw query string and then inserts the hundreds of rows in one statement. It works but does not offer the protections that prepared statements do. I then modified my script to add prepared statements. It works however, it is significantly slower. The script with prepared statements takes much longer to insert the rows than the raw query script, due to the script running through each prepared insert statement one row at a time rather than inserting hundred of rows at a time.</p>
  
  <p>Here's a snippet of the prepared statement code:</p>
  
  <pre><code>for( $j = 0; $j &lt; $abilitiesMax - 2; $j++ ){
    $stmtAbility-&gt;bind_param('iiiii', $abilityArray[$i]["match_id"] , $abilityArray[$i]["player_slot"],
    $abilityArray[$i][$j]["ability"], $abilityArray[$i][$j]["time"], $abilityArray[$i][$j]["level"] );
  
    if(  !($stmtAbility-&gt;execute()) ){      
     echo "&lt;p&gt;$db-&gt;error&lt;/p&gt;";
     echo "&lt;p&gt;ERROR: when trying to insert abilities query&lt;/p&gt;";
    }
  }
  </code></pre>
  
  <p>It gets the job done but only after hundreds upon hundreds of inserts. Is there a way to bind lists or arrays to the bind_param() arguments and just run the $stmtAbility->execute one time or some other method that can speed up performance.</p>
  
  <p>Sorry if this has been asked and answered before. I looked around for a while and found some similar questions but nothing that answered what I was asking for explicitly.</p>