Guys this is now the time when I need a professional to step in.
According to this:
http://dev.mysql.com/doc/refman/5.7/en/truncate-table.html
Truncate, drop, delete, create etc all of the DDl's creates an explicit commit.
But reading here:
http://dev.mysql.com/doc/refman/5.7/en/commit.html
It says: "By default, MySQL runs with autocommit mode enabled. This means that as soon as you execute a statement that updates (modifies) a table, MySQL stores the update on disk to make it permanent. The change cannot be rolled back."
And: "To disable autocommit mode implicitly for a single series of statements, use the START TRANSACTION statement:"
PHP:
START TRANSACTION;
SELECT @A:=SUM(salary) FROM table1 WHERE type=1;
UPDATE table2 SET summary=@A WHERE type=1;
COMMIT;
Thus... My pdo way should work perfectly?
PHP:
<?php
/* Begin a transaction, turning off autocommit */
$dbh->beginTransaction();
/* Change the database schema and data */
$sth = $dbh->exec("TRUNCATE TABLE fruit");
$sth = $dbh->exec("UPDATE dessert
SET name = 'hamburger'");
/* Recognize mistake and roll back changes */
$dbh->rollBack();
/* Database connection is now back in autocommit mode */
?>
However the manuals is still confusing, because it says:
"Logically, TRUNCATE TABLE is similar to a DELETE statement that deletes all rows, or a sequence of DROP TABLE and CREATE TABLE statements. To achieve high performance,
it bypasses the DML method of deleting data. Thus, it cannot be rolled back, it does not cause ON DELETE triggers to fire, and it cannot be performed for InnoDB tables with parent-child foreign key relationships."