0
控制器:如何設置LIKE子句CI
function search()
{
$this->load->model('membership_model');
$query = $this->membership_model->search();
var_dump($query->result());}
型號:
function search()
{
$match = $this->input->post('Search');
$this->db->like('title',$match);
$q = $this->db->get('feeds');
return $q;
}
我想從我的數據庫中選取標題包含$匹配所有行,但它返回我的所有行。我有一個輸入表單,我插入單詞。在模型中,我希望在每個標題中搜索單詞,並僅返回那些包含來自我的輸入表單的單詞的標題。 形式:
echo anchor('site/search','Search')."<br/><br/>";
echo form_input('search','search');
你要去的URL是什麼?你確定'Search'正確地被張貼?你如何提交你的表格? –
檢查模型中您上次執行的查詢。 –
我只在模型中放入第三行,它將所有行都返回給我。這意味着像子句不起作用回聲錨('site/search','搜索')。「
」; echo form_input('search');這是我的形式 – user3313651