我已经为关键字搜索编写了一个方法和模型。但不幸的是,我得到的输出与我的关键字匹配,并且与我键入的关键字没有任何匹配。
例如。如果我输入关键字“grisham”作为作者姓氏,那么我将获取所有其他数据(book_title,auth_firstname,isbn
)作为输出,包括“grisham”(即auth_lastname
)
*但我输入的关键字只与author_lastname匹配。那么为什么显示其他?* 只显示aUth_last名称?
请帮帮我,解决我的问题。
Controller.php这样
function suggestions()
{
$this->load->model('Booksmodel');
$term = $this->input->post('term',TRUE);
$rows = $this->Booksmodel->GetAutocomplete(array('keyword' => $term));
$json_array = array();
foreach ($rows as $row)
array_push($json_array, $row->book_title);
array_push($json_array, $row->auth_firstname);
array_push($json_array, $row->isbn);
array_push($json_array, $row->auth_lastname);
array_push($json_array, $row->publisher_name);
echo json_encode($json_array);
}
model.php
function GetAutocomplete($options = array())
{
$this->load->database();
$this->db->limit('10');
$this->db->select('book_title,auth_firstname,isbn,auth_lastname,publisher_name');
$this->db->like('book_title', $options['keyword']);
$this->db->or_like('auth_firstname', $options['keyword']);
$this->db->or_like('isbn', $options['keyword']);
$this->db->or_like('auth_lastname', $options['keyword']);
$this->db->or_like('publisher_name', $options['keyword']);
$query = $this->db->get('bookdetails');
return $query->result();
}