Q:

Transaction rollback doesnt work

I have the following code in my admin controller:
if ($data = $this->getRequest()->getPost()) {
    if (is_uploaded_file($_FILES['csv_dealers']['tmp_name'])) {
        $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
        try {
            $connection->beginTransaction();

            $connection->query('TRUNCATE TABLE `dealer`');

            $handle = fopen($_FILES['csv_dealers']['tmp_name'], "r");

            while (($data = fgetcsv($handle, 1000000, ",")) !== false) {
                $import = "INSERT INTO `dealers` ..."

                $connection->query($import);
            }

            Mage::getSingleton('adminhtml/session')->addSuccess('...');

            fclose($handle);

            $connection->commit();               
        } catch (Exception $e) {
            $connection->rollback(); //this doesnt work
            Mage::getSingleton('adminhtml/session')->addError('...');
        }
    } else {
        Mage::getSingleton('adminhtml/session')->addError('...');
    }
}

It's supposed to rollback the table if some error occurs, but it doesn't. What am I missing here?

A:

As I was suspecting, TRUNCATE TABLE is causing the transaction to commit.
http://dev.mysql.com/doc/refman/5.5/en/implicit-commit.html

