summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Allard <derek.allard@ellislab.com>2007-10-13 19:00:16 +0200
committerDerek Allard <derek.allard@ellislab.com>2007-10-13 19:00:16 +0200
commitdb43858f537722deef7c9ebc903534ea9be0df60 (patch)
tree8b39cbb6f64d6d572bba464693d91890f7509257
parent6a8f97cd711a8fd545f3fb23edfdbdeb10a61685 (diff)
Added a check for NULL fields in the MySQL database backup utility
-rw-r--r--system/database/drivers/mysql/mysql_utility.php25
-rw-r--r--user_guide/changelog.html1
2 files changed, 22 insertions, 4 deletions
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
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index eb2e3ef7a..d9819d4f3 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -73,6 +73,7 @@ Change Log
<li>Javascript Calendar plugin now uses the months and days from the calendar language file, instead of hard-coded values, internationalizing it.</li>
<li>Removed &quot;rand()&quot; as a listed option from orderby in the <a href="./database/active_record.html">Active Record</a>, as it was MySQL only. </li>
<li>Added titles to all user manual pages.</li>
+ <li>Added a check for NULL fields in the MySQL database backup utility.</li>
<li>Documented the timezones() function in the <a href="./helpers/date_helper.html">Date Helper</a>.</li>
<li>Documented unset_userdata in the <a href="./libraries/sessions.html">Session class</a>.</li>
<li>Fixed a bug in <a href="./libraries/validation.html">Validation</a> where valid_ip() wasn't called properly</li>