简体   繁体   中英

SQL IN condition cakephp

let's say I have a column in my database table that contains a list of comma-separated values like:

MyTable.values = a,b,c,d,e,f,etc....

How do I construct the condition in the find('all') function of cakePHP to retrieve the entries whose MyTable.values contain let's say "c" for example

Thanks

You should be able to use the LIKE operator. Percent-sign is a wildcard.

<?php

$this->Model->find("all", array(
    "conditions" => array("Model.field LIKE" => "%c%")
));
?>

Gotta love that automagic.

Edit: Found it! The complex find conditions page has official documentation on this, though it's kind of buried.

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