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