gpt4 book ai didi

php - 代码点火器搜索

转载 作者:行者123 更新时间:2023-11-29 05:30:20 25 4
gpt4 key购买 nike

你好,我有一点问题

我想在 mysql 中按名称搜索

我在搜索模型中有这段代码

 $this->db->limit($limit, $start);
$this->db->like("name",$by);
$res = $this->db->get('walls');
if ($res->num_rows() > 0)
return $res->result();

$by = "megan"的结果;正在工作

但是当 $by = "megan fox";不工作

在 mysql 名称中我有“megan fox”;

我尝试了 urldecode 但无济于事。

我使用 codeigniter 框架..

有什么想法吗?

最佳答案

 $this->db->limit($limit, $start);
$this->db->like("name",$by);
$res = $this->db->get('walls');
if ($res->num_rows() > 0)
return $res->result();

您可能想要添加 BOTH , LEFT , RIGHT在你的 like()从句示例

$this->db->like("name",$by,'BOTH'); // left and right wild card %name%
$this->db->like("name",$by,'LEFT'); // left wild card %name
$this->db->like("name",$by,'RIGHT'); // right wild card name%

您可以在 http://ellislab.com/codeigniter/user-guide/database/active_record.html 阅读更多内容

关于php - 代码点火器搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15450613/

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