I want to retrieve multiples values from a field. the code I am using this this
$conditions = array('Tag.name'=>$compare);//$compare = array('value1', 'value2',..);
$values = $this->find('all', array('conditions' => $conditions));
But It keeps coming out like this
SELECT `Tag`.`id`, `Tag`.`name`, `Tag`.`count` FROM `tags` AS `Tag` WHERE `Tag`.`name` IN ('tag2', ' tag1', ' one tag')
Problem is it only retrieves the first value given. instead of all the values . How do I get it to select all the values in the array.
What version of Cake are you using?
But the main thing is that your conditions needs to be in a fields array.
Ref, Model::find() API Docs
The reason your query is not working is that you need to move it into that pattern..
So your query would be,
Not sure on your example if you meant to omit it, but always best to include the model you are running the find against 🙂