I know this is thread is a little old, but I'm having the same problem and just can't seem to resolve it. The query being generated is missing conditions for reasons I can't figure out:
-- SELECT `Book`.`book_id`, `Book`.`isbn13`, `Book`.`isbn10`, `Book`.`series`, `Book`.`format`, `Book`.`title`, `Book`.`title_prefix`, `Book`.`title_without_prefix`, `Book`.`subtitle`, `Book`.`language`, `Book`.`pages`, `Book`.`basic`, `Book`.`audience`, `Book`.`age_from`, `Book`.`age_to`, `Book`.`grade_from`, `Book`.`grade_to`, `Book`.`main_desc`, `Book`.`bio_note`, `Book`.`review_quote`, `Book`.`imprint`, `Book`.`publisher`, `Book`.`pub_status`, `Book`.`pub_date`, `Book`.`height`, `Book`.`width`, `Book`.`url`, `Book`.`extras` FROM `titles`.`books` AS `Book` WHERE 1 = 1 LIMIT 20
The weird thing is that when I debug the search action line: debug($this->paginate['conditions'] = $this->Book->parseCriteria($this->passedArgs));
I do get an array with the condition: array( 'Book.title LIKE' => '%sweet%' )I'm not sure where this condition goes missing!
Thanks for anything you can help with.
On Monday, 15 April 2013 19:14:46 UTC-4, cricket wrote:
What does the resulting query look like? Does it include the condition with the submitted name?On Mon, Apr 15, 2013 at 1:44 AM, Muhammad Asyraf <asyra...@gmail.com> wrote:
Actually i already Google several search plugin for CakePHP but most of CakePHP user recommended search plugin from CakeDC. So, i download the plugin from https://github.com/dereuromark/search and load the plugin with code: CakePlugin::load('Search'); in bootstrap.php Then i implement the code for my file controller:public $components = array('Search.Prg');public $presetVars = true; // using the model configurationpublic function find() {$this->Prg->commonProcess();$this->paginate['conditions'] = $this->Patient->parseCriteria($this->passedArgs); $this->set('patients', $this->paginate());}
For the model, i put this code:public $actsAs = array('Search.Searchable');public $filterArgs = array(array('name' => 'name', 'type' => 'query', 'method' => 'filterName'),);public function filterName($data, $field = null) {if (empty($data['name'])) {return array();}$nameField = '%' . $data['name'] . '%';return array('OR' => array($this->alias . '.name LIKE' => $nameField,));}For the view (find.ctp), i put this code for the form: (others code are exactly same as view/index.ctp)<div><?phpecho $this->Form->create('Patient', array('url' => array_merge(array('action' => 'find'), $this->params['pass'])));echo $this->Form->input('name', array('div' => false));echo $this->Form->submit(__('Search'), array('div' => false)); echo $this->Form->end();?></div>What i try to achieve is the search plugin will do searching for "name" from table patients. However, this code seems not working but in the URL, once i do searching for example i "John" as the search term, the URL bar show as patients/find/name:john but the list of record are not showing john record only but still show all records instead of john only.As for the information i use CakePHP ver: 2.3.1. Is it any problem with the codes or any depreciate attributes in the coding? Sorry if this question repeated in this group but i still unable to find any solution. Most of the user claimed that it is easy to use this plugin but i'm still new in CakePHP. Hope someone can help me.Thanks :)--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+u...@googlegroups.com .
To post to this group, send email to cake...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en .
For more options, visit https://groups.google.com/groups/opt_out .
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment