Affects Version/s: None
Fix Version/s: None
Security Level: All
This issue is created automatically through a Github pull request on behalf of ddeboer:
When truncating tables on MySQL >= 5.5, an error is thrown:
SQLSTATE: Syntax error or access violation:
1701 Cannot truncate a table referenced in a foreign key constraint ...
It turns out that with MySQL 5.5.7, `TRUNCATE` behaviour has changed. From the [MySQL docs](http://dev.mysql.com/doc/refman/5.5/en/truncate-table.html):
> TRUNCATE TABLE fails for an InnoDB table if there are any FOREIGN KEY constraints from other tables that reference the table. Foreign key constraints between columns of the same table are permitted.
With this PR foreign key checks are disabled just before and re-enabled just after truncate.
As I encountered this issue using doctrine/data-fixtures, I originally submitted a fix there: https://github.com/doctrine/data-fixtures/pull/127. However, as @deeky666 pointed out, the DBAL is a better place for the fix.