summaryrefslogtreecommitdiffstats
path: root/user_guide
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2011-02-23 17:21:39 +0100
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-02-23 17:21:39 +0100
commite8b8d6824ca0a9bb3cadf88590be20744d71b867 (patch)
tree08f925e324594c37aa181d3c280106ada156afb1 /user_guide
parent9a73f87f748791deeb0047ecbd5ebee01fe11287 (diff)
Added documentation for DB active record insert_batch();
Diffstat (limited to 'user_guide')
-rw-r--r--user_guide/database/active_record.html33
1 files changed, 29 insertions, 4 deletions
diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html
index 30c45fdde..f2f33e212 100644
--- a/user_guide/database/active_record.html
+++ b/user_guide/database/active_record.html
@@ -489,10 +489,10 @@ echo $this-&gt;db-&gt;count_all_results();<br />
<code>
$data = array(<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title' => 'My title' ,<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name' => 'My Name' ,<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'date' => 'My date'<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+&nbsp;&nbsp;&nbsp;'title' => 'My title' ,<br />
+&nbsp;&nbsp;&nbsp;'name' => 'My Name' ,<br />
+&nbsp;&nbsp;&nbsp;'date' => 'My date'<br />
+);<br />
<br />
$this->db->insert('mytable', $data);
<br /><br />
@@ -521,6 +521,31 @@ $this->db->insert('mytable', $object);
<p class="important"><strong>Note:</strong> All values are escaped automatically producing safer queries.</p>
+<h2>$this->db->insert_batch();</h2>
+<p>Generates an insert string based on the data you supply, and runs the query. You can either pass an
+<strong>array</strong> or an <strong>object</strong> to the function. Here is an example using an array:</p>
+
+<code>
+$data = array(<br/>
+&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title' => 'My title' ,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name' => 'My Name' ,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'date' => 'My date'<br />
+&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title' => 'Another title' ,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name' => 'Another Name' ,<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'date' => 'Another date'<br />
+&nbsp;&nbsp;&nbsp;)<br/>
+);<br />
+<br />
+$this->db->insert_batch('mytable', $data);
+<br /><br />
+// Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date'), ('Another title', 'Another name', 'Another date')</code>
+
+<p>The first parameter will contain the table name, the second is an associative array of values.</p>
+
+<p class="important"><strong>Note:</strong> All values are escaped automatically producing safer queries.</p>