On Fri, Apr 8, 2011 at 3:52 PM, Geoff Wiggs <wig...@gmail.com> wrote: > I am having some difficulty getting my head around something I'd like to do > in Cake. I'm not really sure if what I want to do it the 'right' thing. > > I have a file of "Loads" - data that I have loaded into my db for either a > particular time period or analysis approach. > > Each "Load" consists of Invoice records with a key field matching the "Load" > key. Since the Date of the load is the only peice of information contained > in the "Load" record - I wouldn't think that a join relationship would be > efficient. I would like to pass the Load key as a parameter to the Invoice > Controller and use the Load# in the findall() function in the controller. > But along these lines I am unsure of how to pass the parameter to the > Invoice controller correctly. > > Does this make sense? Or am I just making extra work for myself? Can > anyone provide any guidance?
Could you explain the use case a bit more? I'm not sure I understand what you want to do. Do you mean that you want to find all Invoices with a particular load_id? If so ... Load: public $hasMany = array('Invoice'); Invoice: public $belongsTo = array('Load'); public function fetchByLoadId($load_id) { return $this->find( 'all', array( 'fields' => array('*'), 'conditions' => array( $this->alias.'.load_id' => $load_id ), 'recursive' => -1 ) ); } InvoicesController: public function admin_by_load($load_id = null) { $this->set( 'data', $this->Invoice->fetchByLoadId($load_id) ); } routes.php: Router::connect( '/admin/invoices/by_load/:load_id', array( 'admin' => 1, 'controller' => 'invoices', 'action' => 'by_load' ), array( 'load_id' => '[0-9]+', 'pass' => array('load_id') ) ); Something like that? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php