From e8b8d6824ca0a9bb3cadf88590be20744d71b867 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 23 Feb 2011 16:21:39 +0000 Subject: Added documentation for DB active record insert_batch(); --- user_guide/database/active_record.html | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'user_guide') 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->db->count_all_results();
$data = array(
-               'title' => 'My title' ,
-               'name' => 'My Name' ,
-               'date' => 'My date'
-            );
+   'title' => 'My title' ,
+   'name' => 'My Name' ,
+   'date' => 'My date'
+);

$this->db->insert('mytable', $data);

@@ -521,6 +521,31 @@ $this->db->insert('mytable', $object);

Note: All values are escaped automatically producing safer queries.

+

$this->db->insert_batch();

+

Generates an insert string based on the data you supply, and runs the query. You can either pass an +array or an object to the function. Here is an example using an array:

+ + +$data = array(
+   array(
+      'title' => 'My title' ,
+      'name' => 'My Name' ,
+      'date' => 'My date'
+   ),
+   array(
+      'title' => 'Another title' ,
+      'name' => 'Another Name' ,
+      'date' => 'Another date'
+   )
+);
+
+$this->db->insert_batch('mytable', $data); +

+// Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date'), ('Another title', 'Another name', 'Another date')
+ +

The first parameter will contain the table name, the second is an associative array of values.

+ +

Note: All values are escaped automatically producing safer queries.

-- cgit v1.2.3-24-g4f1b