I have a table in which category ids are stored in the DB as comma separated values, so I need to search another array in this comma separated values.
Need to search $required_ids_array
in Posts.category_ids
$required_ids_array = Array (
[0] => 14
[1] => 15
[2] => 16
[3] => 25
[4] => 35
);
if(isset($required_ids_array)){
foreach ($required_ids_array as $storeId) {
$condition = array ();
$condition ['AND'] ['Post.status']=1;
$blogs = $this->Post->find('all', array(
'conditions' => $condition,
'order' => 'Post.id.DESC',
'limit'=>'4',
'FIND_IN_SET(\''.$storeId.'\',Post.category_ids)')
);
}
Thanks in advance
This solution worked for me :)
$blogs = $this->Post->find ( 'all', array (
'conditions' => array (
'Post.status' => 1,
'Post.id !=' => $id,
'FIND_IN_SET(?, Post.category_ids)' => array ($storeId) ),
'limit' => 4,
'order' => 'Blog.modified DESC'
) );