как преобразовать этот код в код CodeIgniter:
search_hotel: -> это CI_Model
return mysql_query("select * from hotel_submits where name LIKE '".$searchterm."'")
я пытаюсь, но есть ошибка:
$query = $this->db->order_by("id", "desc")->like('name', '$searchterm')->get('hotel_submits');
return $query->row();
ошибка:
A PHP Error was encountered
Severity: Warning
Message: mysql_fetch_assoc() expects parameter 1 to be resource, array given
Filename: admin/tour.php
Line Number: 15
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: data
Filename: admin/tour.php
Line Number: 21
код: -> это CI_Controller
$searchterm = $this->input->post('search_hotel');
$result = $this->model_tour->search_hotel($searchterm);
while ($row = mysql_fetch_assoc($result)) { //this is line 15
//giving names to the fields
$data = array (
'name' => $row->name,
);
}
echo json_encode($data); //this is line 21