Posted By

sveggiani on 06/04/09


Tagged

cakephp


Versions (?)

Avoid Cakephp auto adding ID parameter in some finds


 / Published in: PHP
 

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

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

WTF!?

  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  

You need to login to post a comment.