我已经陷入这个阶段一个小时了。
我的目的是使用表 tag_name
进行搜索,如果在 tag_name
中给出 no_result 我想使用具有类似条件的产品名称表。或者我可以从两者中获取结果条件如上。
感谢大家的善意:
function search_products($searchStr)
{
$this->db->select('a.*, b.,c.*,c.id as id_product',FALSE);
$this->db->from('tags_events a ',FALSE);
$this->db->join('products b','a.product_id = b.id ',FALSE);
$this->db->join('products_details c', 'b.id = c.product_id', 'left');
$this->db->where("MATCH (tag_name) AGAINST ('{$searchStr}')OR b.product_name LIKE '%$searchStr%' ", NULL, FALSE);
$this->db->group_by("b.product_name");
$query=$this->db->get();
return $query;
}
最佳答案
我认为如果你使用mysql模式匹配,你的问题就会解决
MySQL 提供标准 SQL 模式匹配以及基于扩展正则表达式的模式匹配形式,类似于 Unix 实用程序(例如 vi、grep 和 sed)所使用的模式匹配。
如果您需要详细解释,可以访问此链接:http://dev.mysql.com/doc/refman/5.0/en/pattern-matching.html
关于php - 在同一查询中使用 like、or、match 的 codeigniter 事件记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24454919/