title: MySQLi Prepared Statements and Transactions
body: <p>Is there a way to do transactions with prepared statements?</p>
  
  <p>I mean can I use the following example with <code>$mysqli-&gt;autocommit(FALSE);</code> and <code>$mysqli-&gt;commit(  );</code> and <code>$mysqli-&gt;rollback(  );</code></p>
  
  <pre><code>//Preparing the statment
  
  $insert_stmt=$mysqli-&gt;prepare("INSERT INTO x VALUES(?,?)")
  or die($mysqli-&gt;error);
  
  //associate variables with the input parameters
  
  $insert_stmt-&gt;bind_param("is", $my_number,$my_string); //i=integer
  
  //Execute the statement multiple times....
  
  for ($my_number = 1; $my_number &lt;= 10; $my_number++) 
  {
      $my_string="row ".$my_number;
      $insert_stmt-&gt;execute() or die ($insert_stmt-&gt;error);
  }
  $insert_stmt-&gt;close();
  </code></pre>
  
  <p>I have looked around but can't find any example of using prepared statements (not PDO):
  <a href="http://php.net/manual/en/mysqli.prepare.php" rel="noreferrer">http://php.net/manual/en/mysqli.prepare.php</a> with transactions, I only find examples like these mentioned here: <a href="http://book.opensourceproject.org.cn/lamp/mysql/mysqlstored/opensource/0596100892/mysqlspp-chp-13-sect-2.html" rel="noreferrer">http://book.opensourceproject.org.cn/lamp/mysql/mysqlstored/opensource/0596100892/mysqlspp-chp-13-sect-2.html</a> where transactions and prepared statements are never inter-mixed.</p>
  
  <p>Would it be wrong to use them together?</p>