diff options
-rw-r--r-- | system/database/DB_active_rec.php | 9 | ||||
-rw-r--r-- | user_guide/changelog.html | 3 | ||||
-rw-r--r-- | user_guide/database/active_record.html | 32 |
3 files changed, 19 insertions, 25 deletions
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index b2638f25c..d58580637 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -447,14 +447,19 @@ class CI_DB_active_record extends CI_DB_driver { $k .= ' =';
}
- if ($v != '')
+ if ($v !== '' AND $v !== NULL)
{
$v = ' '.$this->escape($v);
}
}
else
{
- $k = $this->_protect_identifiers($k, TRUE);
+
+ if ($escape === TRUE)
+ {
+ $k = $this->_protect_identifiers($k, TRUE);
+ }
+
}
$this->ar_where[] = $prefix.$k.$v;
diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 62e4541e0..1efaa6b2a 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -63,7 +63,8 @@ Change Log <li>Active Record
<ul>
<li>Added the ability to prevent escaping in having() clauses.</li>
- </ul>
+ <li>Fixed a bug that wasn't allowing escaping to be turned off if the value of a query was NULL.</li>
+ </ul>
</li>
<li>Config
<ul>
diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index a9889d559..5fbd3bc8e 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -219,8 +219,7 @@ $this->db->join('comments', 'comments.id = blogs.id', <strong>'left'</strong>);< <li><strong>Simple key/value method:</strong>
<code>$this->db->where('name', $name);
- <br /><br />// Produces: WHERE name = 'Joe'
- </code>
+ <br /><br />// Produces: WHERE name = 'Joe' </code>
<p>Notice that the equal sign is added for you.</p>
@@ -229,11 +228,7 @@ $this->db->join('comments', 'comments.id = blogs.id', <strong>'left'</strong>);< <code>$this->db->where('name', $name);<br />
$this->db->where('title', $title);<br />
$this->db->where('status', $status);
- <br /><br />// WHERE = name 'Joe' AND title = 'boss' AND status = 'active'
- </code>
-
-
- </li>
+ <br /><br />// WHERE = name 'Joe' AND title = 'boss' AND status = 'active' </code> </li>
<li><strong>Custom key/value method:</strong>
@@ -241,12 +236,7 @@ $this->db->join('comments', 'comments.id = blogs.id', <strong>'left'</strong>);< <code>$this->db->where('name !=', $name);<br />
$this->db->where('id <', $id);
- <br /><br />// Produces: WHERE name != 'Joe' AND id < 45
- </code>
-
-
-
- </li>
+ <br /><br />// Produces: WHERE name != 'Joe' AND id < 45 </code> </li>
<li><strong>Associative array method:</strong>
@@ -254,29 +244,27 @@ $this->db->join('comments', 'comments.id = blogs.id', <strong>'left'</strong>);< $array = array('name' => $name, 'title' => $title, 'status' => $status);<br /><br />
$this->db->where($array);
- <br /><br />// Produces: WHERE name = 'Joe' AND title = 'boss' AND status = 'active'
- </code>
+ <br /><br />// Produces: WHERE name = 'Joe' AND title = 'boss' AND status = 'active' </code>
<p>You can include your own operators using this method as well:</p>
<code>
$array = array('name !=' => $name, 'id <' => $id, 'date >' => $date);<br /><br />
- $this->db->where($array);</code>
-
- </li>
+ $this->db->where($array);</code> </li>
<li><strong>Custom string:</strong>
<p>You can write your own clauses manually:</p>
<code>
$where = "name='Joe' AND status='boss' OR status='active'";<br /><br />
- $this->db->where($where);</code>
-
- </li>
-</ol>
+ $this->db->where($where);</code></li>
+ </ol>
+<p>$this->db->where() accepts an optional third parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks.</p>
+<p><code> $this->db->where('MATCH (field) AGAINST ("value")', NULL, FALSE);<br />
+</code></p>
<h2>$this->db->or_where();</h2>
<p>This function is identical to the one above, except that multiple instances are joined by OR:</p>
|