Avoid Cakephp auto adding ID parameter in some finds


/ Published in: PHP
Save to your folder(s)

When you have a URL like this
http://mysite/newsletters/index/2007

The find('first') method adds the 2007 value as ID parameter

WTF!?


Copy this code and paste it in your HTML
  1. function index( $year = null ){
  2.  
  3. // ultimo newsletter activo
  4. $last_newsletter = $this->Newsletter->find( 'first', array('conditions' => array('Newsletter.id IS NOT NULL') ) );
  5. $this->set('last_newsletter', $last_newsletter);
  6.  
  7. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.