Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

Commit

Permalink
Don't loose mysql FOREIGN_KEY_CHECKS status
Browse files Browse the repository at this point in the history
  • Loading branch information
gsouf authored and sebastianbergmann committed Jan 23, 2018
1 parent fa2b2a3 commit b8b728e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Operation/Truncate.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ public function execute(Connection $connection, IDataSet $dataSet)
private function disableForeignKeyChecksForMysql(Connection $connection)
{
if ($this->isMysql($connection)) {
$connection->getConnection()->query('SET @PHPUNIT_OLD_FOREIGN_KEY_CHECKS = @@FOREIGN_KEY_CHECKS');
$connection->getConnection()->query('SET FOREIGN_KEY_CHECKS = 0');
}
}

private function enableForeignKeyChecksForMysql(Connection $connection)
{
if ($this->isMysql($connection)) {
$connection->getConnection()->query('SET FOREIGN_KEY_CHECKS = 1');
$connection->getConnection()->query('SET FOREIGN_KEY_CHECKS=@PHPUNIT_OLD_FOREIGN_KEY_CHECKS');
}
}

Expand Down

0 comments on commit b8b728e

Please sign in to comment.