take below, using Query Builder Class:
public function search($saq)
{
$array=$this->db
->select()
->order_by('id', 'DESC')
->where("name Like '$saq%'")
->get('products');
return $array->result();
}
Would this give a correct CodeIgniter query ?
Codeigniter's query builder has a function like() you can use, using your example:
public function search($saq) {
$query=$this->db
->select()
->order_by('id', 'DESC')
->like('name', $saq, 'after')
->get('products');
return $query->result();
}
more information here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.