Welcome Guest, Not a member yet? Register   Sign In
Update Batch

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.


The general usage of update_batch is like this:
PHP Code:
$data = array(
'title' => 'My title' ,
'name' => 'My Name 2' ,
'date' => 'My date 2'
'title' => 'Another title' ,
'name' => 'Another Name 2' ,
'date' => 'Another date 2'


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.

Theme © iAndrew 2016 - Forum software by © MyBB