summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-12-20 15:25:06 +0100
committerAndrey Andreev <narf@bofh.bg>2012-12-20 15:25:06 +0100
commit16c26ff619d460228066e25ab2bc314925b85760 (patch)
tree9c70b4cb5d14d4f9e560288d78dd25f258d7ed92 /system
parent72ed4c322652d88bf90ddfe8b8c9a563c51e4660 (diff)
parentbee50e7eebdf0f0aa3072958bb30e3235b3fc4a8 (diff)
Merge pull request #2087 from AndrewPodner/develop
Resolves issue #2081 : Foreign Key Checks
Diffstat (limited to 'system')
-rw-r--r--system/database/DB_utility.php15
-rw-r--r--system/database/drivers/mysql/mysql_utility.php13
-rw-r--r--system/database/drivers/mysqli/mysqli_utility.php13
3 files changed, 34 insertions, 7 deletions
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
index c4140aef3..aff3cf8c2 100644
--- a/system/database/DB_utility.php
+++ b/system/database/DB_utility.php
@@ -320,13 +320,14 @@ abstract class CI_DB_utility {
// Set up our default preferences
$prefs = array(
- 'tables' => array(),
- 'ignore' => array(),
- 'filename' => '',
- 'format' => 'gzip', // gzip, zip, txt
- 'add_drop' => TRUE,
- 'add_insert' => TRUE,
- 'newline' => "\n"
+ 'tables' => array(),
+ 'ignore' => array(),
+ 'filename' => '',
+ 'format' => 'gzip', // gzip, zip, txt
+ 'add_drop' => TRUE,
+ 'add_insert' => TRUE,
+ 'newline' => "\n",
+ 'foreign_key_checks' => TRUE
);
// Did the user submit any preferences? If so set them....
diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php
index 8aa051755..f118033dc 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 foreign key checks?
+ if ($foreign_key_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 foreign key checks?
+ if ($foreign_key_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..2edf38cf5 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 foreign key checks?
+ if ($foreign_key_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 foreign key checks?
+ if ($foreign_key_checks === FALSE)
+ {
+ $output .= "SET foreign_key_checks = 1;".$newline;
+ }
+
return $output;
}