diff options
Diffstat (limited to 'user_guide')
-rw-r--r-- | user_guide/changelog.html | 1 | ||||
-rw-r--r-- | user_guide/database/active_record.html | 26 |
2 files changed, 24 insertions, 3 deletions
diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 612c4db62..8853969c4 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -68,6 +68,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 "rand()" 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 'random' as an <kbd>order_by()</kbd> option in <a href="./database/active_record.html">Active Record</a>.</li>
+ <li>Added <kbd>where_in()</kbd> to <a href="./database/active_record.html">Active Record</a>.</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 <kbd>timezones()</kbd> function in the <a href="./helpers/date_helper.html">Date Helper</a>.</li>
diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index 739d56a15..aafef33b5 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -263,11 +263,31 @@ $this->db->where('name !=', $name);<br /> $this->db->or_where('id >', $id);
<br />
<br />// Produces: WHERE name != 'Joe' OR id > 50</code>
-
-
-
<p class="important">Note: or_where() was formerly known as orwhere(), which has been deprecated.</p>
+
+
+<h2>$this->db->where_in();</h2>
+<p>This function is used to write WHERE clauses that contain the IN keyword.</p>
+
+<p><code>
+ $names = array('frank', 'Todd', 'James');<br />
+ $this->db->where_in('username', $names);<br />
+ // Produces: AND WHERE username IN ('frank', 'Todd', 'James')</code></p>
+<p>An optional third parameter can be used to specify if the WHERE statement should be separated with "OR" or "AND" in the event of multiple WHERE calls. The default is "AND".</p>
+<p><code>$names = array('frank', 'Todd', 'James');<br />
+ <br />
+ $this->db->where('usergroup', '5')<br />
+$this->db->where_in('username', $names);<br />
+// Produces: WHERE usergroup = '5' AND WHERE username IN ('frank', 'Todd', 'James')<br />
+<br />
+$this->db->where('usergroup', '5')<br />
+$this->db->where_in('username', $names, 'and');<br />
+// Produces: WHERE usergroup = '5' AND WHERE username IN ('frank', 'Todd', 'James')<br />
+<br />
+$this->db->where('usergroup', '5')<br />
+$this->db->where_in('username', $names, 'or');<br />
+// Produces: WHERE usergroup = '5' OR WHERE username IN ('frank', 'Todd', 'James')</code></p>
<h2>$this->db->like();</h2>
<p>This function enables you to generate <strong>LIKE</strong> clauses, useful for doing searches.</p>
|