diff options
author | Andrew Podner <a.podner@me.com> | 2012-12-19 20:15:41 +0100 |
---|---|---|
committer | Andrew Podner <a.podner@me.com> | 2012-12-19 20:15:41 +0100 |
commit | 79494dde1c53b671f279e5c5fab2ae03a9ff0353 (patch) | |
tree | e38cac2f093958b2e75cbda38429ca34bc2a38e5 /system/database/drivers | |
parent | a9162502512e5eca4fa257689e7a250be900968f (diff) |
Resolves issue #2081 : provides an option to include statements to disable and re-enable foreign key checks in a MySQL database backup output statement.
Diffstat (limited to 'system/database/drivers')
-rw-r--r-- | system/database/drivers/mysql/mysql_utility.php | 13 | ||||
-rw-r--r-- | system/database/drivers/mysqli/mysqli_utility.php | 13 |
2 files changed, 26 insertions, 0 deletions
diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php index 8aa051755..e2de82d0b 100644 --- a/system/database/drivers/mysql/mysql_utility.php +++ b/system/database/drivers/mysql/mysql_utility.php @@ -76,6 +76,13 @@ class CI_DB_mysql_utility extends CI_DB_utility { // Build the output $output = ''; + + // Do we need to include a statement to disable FK checks? + if ($fk_checks === FALSE) + { + $output .= "SET foreign_key_checks = 0;".$newline; + } + foreach ( (array) $tables as $table) { // Is the table in the "ignore" list? @@ -181,6 +188,12 @@ class CI_DB_mysql_utility extends CI_DB_utility { $output .= $newline.$newline; } + // Do we need to include a statement to re-enable FK checks? + if ($fk_checks === FALSE) + { + $output .= "SET foreign_key_checks = 1;".$newline; + } + return $output; } diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php index 345691e84..ff4949046 100644 --- a/system/database/drivers/mysqli/mysqli_utility.php +++ b/system/database/drivers/mysqli/mysqli_utility.php @@ -76,6 +76,13 @@ class CI_DB_mysqli_utility extends CI_DB_utility { // Build the output $output = ''; + + // Do we need to include a statement to disable FK checks? + if ($fk_checks === FALSE) + { + $output .= "SET foreign_key_checks = 0;".$newline; + } + foreach ( (array) $tables as $table) { // Is the table in the "ignore" list? @@ -181,6 +188,12 @@ class CI_DB_mysqli_utility extends CI_DB_utility { $output .= $newline.$newline; } + // Do we need to include a statement to re-enable FK checks? + if ($fk_checks === FALSE) + { + $output .= "SET foreign_key_checks = 1;".$newline; + } + return $output; } |