$conditions = array(); if (isset($this->passedArgs['released'])) { $conditions['Game.released'] = '%' + $this->passedArgs['released'] + '%'; }
... $this->Game->find('all', array('conditions' => $conditions)); You may want to sanitize. On Sun, Dec 7, 2008 at 7:16 AM, navilon <[EMAIL PROTECTED]> wrote: > > REF: http://book.cakephp.org/view/541/Named-parameters > > I would like to pass optional named variables into my controller to > limit the data received from the database. (the variables shouldnt hve > to be passed in any particular order and each variable passed is > optional) > > $this->Game->find( > 'all', > array( > 'conditions' => > array( > 'Game.name LIKE ' => > '%'.$this->passedArgs['name'].'%', > 'Game.released' => '%' > + $this->passedArgs['released'] + '%', > 'Game.date LIKE' => > '%' + $this->passedArgs['date'] + '%', > 'Esrb.name LIKE' => > '%' + $this->passedArgs['esrb'] + '%' > ) > ) > ) > > If all variables are passed this works fine, however if only a few are > passed i get an error similar to this: > Notice (8): Undefined index: released > > Is there something I am missing? Or is there a better method? > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---