我想限制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与任何列名称一起使用。 –