sonoton345 Posted May 22, 2009 Share Posted May 22, 2009 I just started learning cakePHP framework and need help in doing a quick search like having a table of jobs and I want to search by keyword say "web designer". This is what I tried but it's just returning everything from the table. Thanks.. <?php if (!empty($this->data)) { $title = $this ->Sanitize->paranoid($this->data['title']); //retrieve keyword from view form $result = $this->Postjob->findAll("Postjob.title LIKE '%".$title."%'"); $this->set('result', $result); } ?> Link to comment https://forums.phpfreaks.com/topic/159297-searching-by-keyword-in-cakephp/ Share on other sites More sharing options...
ehutchison Posted May 26, 2009 Share Posted May 26, 2009 From what I understand with cake, there are two ways to do a query. The cake way http://book.cakephp.org/view/73/Retrieving-Your-Data using the find command. <?php $result = $this->Postjob->find('list', array('conditions'=>array("Postjob.title LIKE'=>'%'.$title.'%'))); ?> The other method, which should not be used often in my opinion http://book.cakephp.org/view/456/query <?php $result = $this->Postjob->query("SELECT * FROM WHERE Postjob.title LIKE '%".$title."%'"); ?> I hope this helps. Link to comment https://forums.phpfreaks.com/topic/159297-searching-by-keyword-in-cakephp/#findComment-842382 Share on other sites More sharing options...
sonoton345 Posted June 10, 2009 Author Share Posted June 10, 2009 Thanks for this, I'll try it out... Link to comment https://forums.phpfreaks.com/topic/159297-searching-by-keyword-in-cakephp/#findComment-853193 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.