Chi
0
Q:

codeigniter where_not_in

$names = array('Frank', 'Todd', 'James');
$this->db->where_not_in('username', $names);
// Produces: WHERE username NOT IN ('Frank', 'Todd', 'James')
1
$this->db->select('*')->from('my_table')
        ->group_start()
                ->where('a', 'a')
                ->or_group_start()
                        ->where('b', 'b')
                        ->where('c', 'c')
                ->group_end()
        ->group_end()
        ->where('d', 'd')
->get();

// Generates:
// SELECT * FROM (`my_table`) WHERE ( `a` = 'a' OR ( `b` = 'b' AND `c` = 'c' ) ) AND `d` = 'd'
1
$this->db->select('ae_users.employee_id, ae_users.emp_name, ae_users.emp_name2, ae_users.emp_name3');
		$this->db->from('ae_users');                
		$this->db->where_in('ae_users.employee_id',$employee_ids);
     
		$query =$this->db->get();
             
		if ($query->num_rows()) {
			return $query->result_array();
		} else {
			return 0;
		}
0
$this->db->like('title', 'match'); $this->db->or_like('body', $match);
// WHERE `title` LIKE '%match%' ESCAPE '!' OR  `body` LIKE '%match%' ESCAPE '!'
0
$table = "my_table";
$id = 1;
$update = ["status"=>"working"];
//Edit just above /\ if you don't need extra "where" clause
$query = $this->db->select()
            ->from($table)
            ->where('id', $id)
            ->get_compiled_select();
$data = $this->db->query("$query FOR UPDATE")->row_array();
$this->db->where('id', $data['id'])->update($table,$update);
-1

New to Communities?

Join the community