• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
update_batch() where

I've been looking for a solution for my problem for a while now, but I cannot find the right answer. Perhaps because there isn't one, but that's why I am here.

I want to update alot of rows at once, I use update_batch() for this which works. But it lacks something I really need. I need to specify another where.

I am building a permission system and I want to update all the permissions of a group at once. I have a table with a group id, a permission id and a value. I can update the value based on the permission id, but I want to update the value based on the group id AND permission id.

What would be the best approach to do this?

public function update(){
        $gid = $this->input->post('gid');
            $this->session->set_flashdata('success', 'Successfully updated permissions.');
            $this->session->set_flashdata('errors', 'Something went wrong while updating the permissions.');
public function update_permission($gid){
        $data = array(
                    'gp_permissionid' => 1,
                    'gp_value' => $this->input->post(''),

        $query = $this->db->update_batch('table_name', $data, 'gp_permissionid');
        if($this->db->trans_status() === TRUE){
            return true;
            return true;

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.