codeigniter 3 limit
// Produces: LIMIT 20, 10 (in MySQL. Other databases have slightly different syntax)
$this->db->limit(10, 20);
$this->db->limit(10); // Produces: LIMIT 10
codeigniter 3 limit
// Produces: LIMIT 20, 10 (in MySQL. Other databases have slightly different syntax)
$this->db->limit(10, 20);
$this->db->limit(10); // Produces: LIMIT 10
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;
}
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; // stop CI adding backticks
$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();
// echo '<pre>'; print_r($this->db->last_query());exit;
if ($query->num_rows()) {
return $query->result_array();
} else {
return 0;
}
cideigniter orLike()
$this->db->like('title', 'match'); $this->db->or_like('body', $match);
// WHERE `title` LIKE '%match%' ESCAPE '!' OR `body` LIKE '%match%' ESCAPE '!'
codeigniter select for update
$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);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us