I am working on finding messages in my project, and here are two models: Msgcontent and Msgblock. Relationship is Msgblock hasMany Msgcontent. What I want to do is get all the Msgblock entries containing Msgcontent with some keyword searches. My code is as follows:
if($keyword) { $conditions['and'] = array( 'Msgcontent.content LIKE'=>'%'.$keyword.'%', 'Msgcontent.content <>'=>'' ); $results = $this->Msgblock->Msgcontent->find('all',array('group'=>array('Msgblock.chatsessionid'),'conditions'=>$conditions)); }
This doesn't seem to be a very good job. Is there a better solution? Thanks.
source share