summaryrefslogtreecommitdiffstats
path: root/user_guide/database
diff options
context:
space:
mode:
authorDerek Allard <derek.allard@ellislab.com>2007-12-19 00:55:06 +0100
committerDerek Allard <derek.allard@ellislab.com>2007-12-19 00:55:06 +0100
commit80dd702d4c46552a3d1f94c5083c83eeff333b45 (patch)
treeb51f9ef9dfb3b1ff2939caf81d65c3f89947b3dd /user_guide/database
parent6ddb5a17ae1a0a75ca75f846dbb7d3a98f1902a3 (diff)
Added where_in() to Active Record.
Diffstat (limited to 'user_guide/database')
-rw-r--r--user_guide/database/active_record.html26
1 files changed, 23 insertions, 3 deletions
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 &quot;OR&quot; or &quot;AND&quot; in the event of multiple WHERE calls. The default is &quot;AND&quot;.</p>
+<p><code>$names = array('frank', 'Todd', 'James');<br />
+ <br />
+ $this-&gt;db-&gt;where('usergroup', '5')<br />
+$this-&gt;db-&gt;where_in('username', $names);<br />
+// Produces: WHERE usergroup = '5' AND WHERE username IN ('frank', 'Todd', 'James')<br />
+<br />
+$this-&gt;db-&gt;where('usergroup', '5')<br />
+$this-&gt;db-&gt;where_in('username', $names, 'and');<br />
+// Produces: WHERE usergroup = '5' AND WHERE username IN ('frank', 'Todd', 'James')<br />
+<br />
+$this-&gt;db-&gt;where('usergroup', '5')<br />
+$this-&gt;db-&gt;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>