Thanks for answering , you are correct this example does not going with the point of prepared statements. It was just an example, i wanted to stay at the commit part.
Let's say that the code is like this , with two individual queries
include('config/functions.php');
$mysqli = connectionToDb();
$mysqli->autocommit(FALSE);
$stmt = $mysqli->prepare("INSERT INTO users (first_name,last_name) VALUES (?,?)");
$stmt->bind_param('ss', $fn, $ln);
$fn = 'stelios';
$ln = 'stelios2';
$stmt->execute();
$stmt->close();
$stmt = $mysqli->prepare("INSERT INTO customers (first_name,last_name) VALUES (?,?)");
$stmt->bind_param('ss', $fn, $ln);
$fn = 'stelios';
$ln = 'stelios2';
$stmt->execute();
$stmt->close();
var_dump($mysqli->commit());
$mysqli->close();
My point with this code is to write to two different tables and to be sure that all the queries executed successfully.
I want the second query to be executed ONLY if the first query succeeded and if the second query fails then the first query must rollback.
I have some mechanisms (not shown here) in order to make sure that the first query is succeeded. Then after a successful second query i'm calling commit and everything works but the return value is FALSE.
If i comment out commit in this code, then nothing is written in the tables.
so this code returns TRUE to you ?