gpt4 book ai didi

mysql - 如何设置LIKE子句CI

转载 作者:行者123 更新时间:2023-11-30 00:37:38 25 4
gpt4 key购买 nike

Controller :

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;
}

我想从数据库中选择 title 包含 $match 的所有行,但它会返回所有行。我有一个输入表单,可以在其中插入单词。在模型中,我想搜索每个标题中的单词,并仅返回包含输入表单中的单词的那些标题。形式:

echo anchor('site/search','Search')."<br/><br/>";
echo form_input('search','search');

最佳答案

我不太明白这个问题,但我认为这段代码就是你所需要的

型号:

function search($match){
$this->db->like('title',$match);
$q = $this->db->get('feeds');
return $q->result();
}

Controller :

function search_title()
{
$this->load->model('membership_model');
$search_value = $this->input->post('search');
$this->data['title'] = $this->membership_model->search($search_value );
}

查看:

 <table>
<?php foreach($title as $value) : ?>
<tr>
<td> <?=$value->nameofcolumn; ?> </tr> //change the word nameofcolumn to the name of the column in your database what column you want to fetch
</tr>
<?php endforeach; ?>
</table>

关于mysql - 如何设置LIKE子句CI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22027381/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com