Cannot rollback transaction in Zend Framework

mysql, transactions, zend-framework

Solution

We can't get this question out of the list of "unanswered" questions on StackOverflow unless there is at least one answer with an upvote. So I'm repeating the solution you discussed above in the comments.

@nos suggests:

Is your DB by any chance MySQL using MyISAM tables ? They don't support transactions. You'd have to use InnoDB tables if you want transaction support.

@Billy responds:

Yes, I am using MyISAM tables. I have changed to InnoDB tables and it works. Thanks.

(I've marked this as a community wiki answer so I don't get any points from it.)

Problem

I use the following code for transaction in Zend Framework but the rollback function doesn't work (Data is inserted into the database by insertSome($data)). What's wrong? ``` $db->beginTransaction(); try{ $model->insertSome($data); $model->insertAll($data2); //this line cannot be run and the whole transaction should be rolled back. $db->commit(); } catch (Exception $e) { $db->rollBack(); echo $e->getMessage(); } ```

Original source