diff options
Diffstat (limited to 'user_guide/database')
-rw-r--r-- | user_guide/database/active_record.html | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index 812deb90c..64596e271 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -517,7 +517,7 @@ $this->db->insert('mytable', $object); <br /><br /> // Produces: INSERT INTO mytable (title, content, date) VALUES ('My Title', 'My Content', 'My Date')</code> -<p>The first parameter will contain the table name, the second is an associative array of values.</p> +<p>The first parameter will contain the table name, the second is an object.</p> <p class="important"><strong>Note:</strong> All values are escaped automatically producing safer queries.</p> @@ -545,6 +545,30 @@ $this->db->insert_batch('mytable', $data); <p>The first parameter will contain the table name, the second is an associative array of values.</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/> + array(<br /> + 'title' => 'My title' ,<br /> + 'name' => 'My Name' ,<br /> + 'date' => 'My date'<br /> + ),<br /> + array(<br /> + 'title' => 'Another title' ,<br /> + 'name' => 'Another Name' ,<br /> + 'date' => 'Another date'<br /> + )<br/> +);<br /> +<br /> +$this->db->update_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> |