我想限制CodeIgniter 3中的get_where函數的1行。出於某種原因它仍然返回所有行。需要使用限制1與get_where函數的幫助
有誰知道我該如何做這項工作?謝謝!
public function getNotes($applicant_id,$client_id,$last_note)
{
/*The notes are displayed by the applicant id that is passed by the $_GET variable from the Note controller
But just to be extra safe and make sure only the freelancer who is signed in can view the it will only show if the
session client id matched the client ID in the db */
$limit = $last_note == true ? "LIMIT 1" : "";
$this->db->order_by('client_notes_id', 'DESC');
$qry = $this->db->get_where("client_notes", ["applicant_id" => $applicant_id, "client_id" => $client_id], $limit);
try {
$result = $qry->result();
return $result;
} catch (Exception $e) {
// fb($e->getMessage());
}
}
如果沒有ORDERBY子句,限制不會起作用,因此在限制之前將其添加,然後它將工作。您無法將ORDERBY與任何列名稱一起使用。 –