From 45697901e4a44ecf1411a21a6014c8ff16e20c91 Mon Sep 17 00:00:00 2001
From: saintnicster You may also use the $this->db->set() function described above when performing updates. Generates an update 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: The first parameter will contain the table name, the second is an associative array of values, the third parameter is the where key. Note: All values are escaped automatically producing safer queries.
)
);
-$this->db->update_batch('mytable', $data);
+$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')
@@ -666,6 +666,41 @@ You can optionally pass this information directly into the update function as a
$this->db->update_batch();
+
+$data = array(
+
+
+ array(
+ 'title' => 'My title' ,
+ 'name' => 'My Name 2' ,
+ 'date' => 'My date 2'
+ ),
+ array(
+ 'title' => 'Another title' ,
+ 'name' => 'Another Name 2' ,
+ 'date' => 'Another date 2'
+ )
+);
+
+$this->db->update_batch('mytable', $data, 'title');
+
+// Produces:
+// UPDATE `mytable` SET `name` = CASE
+// WHEN `title` = 'My title' THEN 'My Name 2'
+// WHEN `title` = 'Another title' THEN 'Another Name 2'
+// ELSE `name` END,
+// `date` = CASE
+// WHEN `title` = 'My title' THEN 'My date 2'
+// WHEN `title` = 'Another title' THEN 'Another date 2'
+// ELSE `date` END
+// WHERE `title` IN ('My title','Another title')Deleting Data
--
cgit v1.2.3-24-g4f1b
From 19277f05c20a3de4beaebcac722659a0ed30a374 Mon Sep 17 00:00:00 2001
From: Adrian Macneil
An optional third parameter can be used to specify which existing column to add the new column after.
+
+$this->dbforge->add_column('table_name', $fields, 'after_field');
+
Used to remove a column from a table.
$this->dbforge->drop_column('table_name', 'column_to_drop');