[英]How to search separated by comma value in cakephp
Need help in cakephp 在cakephp中需要帮助
I have a field furnished_details
in a table and its content is below value (separated by comma). 我在表中有一个
furnished_details
字段,其内容低于值(用逗号分隔)。 eg . 例如。
Double Bed,Flat TV : small (19"),Mirror,Extra storage,Window AC,Ceiling Fan,Lamp,Chair,Armoire,Mini-Fridge
双人床,平板电视:小号(19英寸),镜子,额外储藏,窗户空调,吊扇,台灯,椅子,扶手椅,迷你冰箱
Now in advanced search after submitting form, I store array value in a string separated by commas. 现在,在提交表单后进行高级搜索时,我将数组值存储在以逗号分隔的字符串中。 eg .
例如。
TV,Bed,Linens Provided,Window AC,Ceiling Fan,Lamp,Chair,Armoire,Desk,Night stand,Extra storage
电视,床,提供的床单,空调AC,吊扇,灯,椅子,钟房,桌子,床头柜,额外的存储空间
I just use 我只是用
$conditions[]=array("MATCH(Room.furnished_details) AGAINST('$ame' IN BOOLEAN MODE)" );
but I don't get actual result . 但是我没有得到实际结果。
You want to search for several words (that are comma separated) inside a database field that contains other words that are comma separated? 您要在包含其他逗号分隔的单词的数据库字段内搜索几个单词(逗号分隔)吗? If I get it right, it's bound to get ugly.
如果我做对了,那肯定会变得丑陋。
The only way I can think of is to take your string, explode(',', $string), and then loop on this array to build a LIKE statement for each of your word. 我能想到的唯一方法是获取字符串explode(',',$ string),然后在此数组上循环为每个单词构建一个LIKE语句。
I really advise to change your database structure though, why do you have a comma separated field for something that looks (to me) as if it should be a separate table altogether? 我确实建议更改您的数据库结构,为什么对我来说看起来好像应该是一个单独的表的东西有一个逗号分隔的字段?
用户MySQL的FIND_IN_SET函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.