Example 1: update in codeigniter query
$data = array( 'title' => $title, 'name' => $name, 'date' => $date ); $this->db->where('id', $id); $this->db->update('mytable', $data);
Example 2: where_in codeigniter
$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; }
Example 3: codeigniter where order by
$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); $this->db->_protect_identifiers = FALSE; $order = sprintf('FIELD(ae_users.employee_id, %s)', implode(', ', $employee_ids)); $this->db->order_by($order); $this->db->_protect_identifiers = TRUE; $query =$this->db->get(); if ($query->num_rows()) { return $query->result_array(); } else { return 0; }
Comments
Post a Comment