Update Batch - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Update Batch (/showthread.php?tid=66156) |
Update Batch - sapurah - 09-14-2016 Hello. I have a form that contains a set detail. Each set may contain multiple items in it. For example: SET01 contains ITEM01, ITEM02. I have no problem inserting new sets and this is the script that I use to insert new sets: $data = array(); foreach($values['item'] as $item) { $tempdata = array( 'id' => null, 'code' => strtoupper($values['code']), 'name' => strtoupper($values['name']), 'disc_id' => $values['discipline'], 'item_id' => $item, 'type' => $values['type'] ); array_push($data, $tempdata); } $this->db->insert_batch('tblsets', $data); When I do an update to an existing set record, I can add new items to the set and remove any of the items as well. How do I do the update statement. I tried update_batch but it doesn't seem to work. Appreciate if someone could help me with this. Thanks RE: Update Batch - Wouter60 - 09-14-2016 The general usage of update_batch is like this: PHP Code: $data = array( So you need an array in which each element is an array also. The second level contains the condition (produces "WHERE title='My title'") and the field names that must be updated, with the new values for each field. |