我想用codeigniter在数据库中搜索多个行中的一定数量的关键字。
我的代码如下所示:
$search = array('search goes here');
$keywords = explode(' ', $search);
$this->db->like('nume', $search);
$this->db->or_like('id', $search);
$this->db->or_like('description', $search);
$this->db->or_like('code', $search);
$query = $this->db->get('property');
$config['total_rows'] = $query->num_rows();
$this->pagination->initialize($config);
$this->db->like('nume', $search);
$this->db->or_like('id', $search);
$this->db->or_like('description', $search);
$this->db->or_like('code', $search);
$this->db->limit($config['per_page'], $this->uri->segment(4));
$this->db->order_by('added_date', 'DESC');
$query = $this->db->get("property");
$properties = $data['properties'] = $query->result();
我想要的是:
foreach($keywords as $keyword) {
//some code that will search the database by each keyword
}