简体   繁体   中英

How to search separated by comma value in cakephp

Need help in cakephp

I have a field furnished_details in a table and its content is below value (separated by comma). eg .

Double Bed,Flat TV : small (19"),Mirror,Extra storage,Window AC,Ceiling Fan,Lamp,Chair,Armoire,Mini-Fridge

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

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.

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函数。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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