Reputation: 13
Hi I have a code in which I am sending a keyword in URL so when we click on link its going to our website so for that I am checking what keyword value is coming in URL in my controller
$keyword= $this->params['url']['keyword'];
$dUsers = $this->Db_user->find(
'all',
array(
'conditions'=>array('Db_user.area_of_expertise'=>$keyword),
'order'=>array('Db_user.last_name'=>'asc')
)
);
So my databse has keywod value like : ab ab,bc,ca ab,cd so what is happening by this its giving only ab keyword in result but I need all 3 result which have my keyword in DB so for it I tried to make it like
'Db_user.area_of_expertise'=>'%keyword%'
also tried:
Db_user.area_of_expertise'=>'%'.keyword.'%'
But after it getting no results.
Upvotes: 0
Views: 63
Reputation: 583
You could be using the query method for your custom queries find reference below http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#model-query
Upvotes: -2
Reputation: 37616
Just use in your conditions array:
'Db_user.area_of_expertise LIKE' => '%'.keyword.'%'
Upvotes: 4