From db43858f537722deef7c9ebc903534ea9be0df60 Mon Sep 17 00:00:00 2001 From: Derek Allard Date: Sat, 13 Oct 2007 17:00:16 +0000 Subject: Added a check for NULL fields in the MySQL database backup utility --- system/database/drivers/mysql/mysql_utility.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'system/database') diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php index 0d192147d..54c110e09 100644 --- a/system/database/drivers/mysql/mysql_utility.php +++ b/system/database/drivers/mysql/mysql_utility.php @@ -218,14 +218,31 @@ class CI_DB_mysql_utility extends CI_DB_utility { $v = str_replace('\\\n', '\n', $v); $v = str_replace('\\\r', '\r', $v); $v = str_replace('\\\t', '\t', $v); - - // Escape the data if it's not an integer type - $val_str .= ($is_int[$i] == FALSE) ? $this->db->escape($v) : $v; - $val_str .= ', '; + + // Is the value NULL? + if ($v == NULL) + { + $val_str .= 'NULL'; + } + else + { + // Escape the data if it's not an integer + if ($is_int[$i] == FALSE) + { + $val_str .= $this->db->escape($v); + } + else + { + $val_str .= $v; + } + } + // Append a comma + $val_str .= ', '; $i++; } + // Remove the comma at the end of the string $val_str = preg_replace( "/, $/" , "" , $val_str); // Build the INSERT string -- cgit v1.2.3-24-g4f1b