简体   繁体   English

当搜索词在 codeigniter 查询中包含 '(' 时没有结果

[英]No results when search term include '(' in codeigniter query

I'm trying to search string using CI model.我正在尝试使用 CI 模型搜索字符串。 Here is the code written for it.这是为它编写的代码。

$test_name = "TSH ( Thyroid stimulating harmone)";
$this->db->like('test_name',$test_name);

Above query when executed gives me zero result.上面的查询在执行时给我零结果。 But if I change my database column and replace '(' by '{' or something else then it shows results by executing above code.但是,如果我更改我的数据库列并将 '(' 替换为 '{' 或其他内容,那么它会通过执行上面的代码来显示结果。

new $test_name variable becomes "TSH { T..."}.

But the requirements is to use the string containing '(' only.但要求是只使用包含 '(' 的字符串。

How should i carry forward?我应该如何发扬光大? Please do let me know if additional information is required.如果需要其他信息,请告诉我。

I don't think like() will help you much with your search needs.我认为like()不会对您的搜索需求有太大帮助。 you use a where() function containing with LIKE clause.您使用包含LIKE子句的where()函数。

$keyword="TSH ( Thyroid stimulating harmone)"; 

$this->db->select('*')->from('table')->where("column LIKE '%$keyword%'")->get()->result_array(); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM