I have a simple try catch which is not operating how I would expect. This is my first try at using transactions with PDO:
try
{
$dbo = Db::init();
$dbo->beginTransaction();
$dbo->exec("TRUNCATE TABLE {$this->table}");
$dbo->exec($insert);
$dbo->commit();
}
catch(Exception $e)
{
$dbo->rollBack();
echo 'Failed to sync ' . $this->table;
}
The problem is, if the $dbo->exec($insert); fails, the $dbo->exec("TRUNCATE TABLE {$this->table}"); does not get rolled back. Any ideas?
TRUNCATEcannot be rolled back. UseDELETEinstead.