hi folks, this is a common issue, and there's a really good solution presented by ad7Six in this thread:
http://tinyurl.com/2thlcb hth jon On 5/13/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I don't know if this will work... but one idea would be to put the > associations in the model constructor. > > class Door extends AppModel { > function __contruct(){ > //dont forget to call the parent constructor! > $args = func_get_args(); > call_user_func_array(array($this, 'parent::__construct'), > $args); > > // put binding code here// > } > } > > You are still using bindModel, but at least the model logic, would be > in the model. > > good luck, > cook > > > On May 13, 4:08 am, johnvv <[EMAIL PROTECTED]> wrote: > > I've heard that it's good practice to put associations in the model > > (rather than using bindModel) but when declairing a HABTM > > relationship, I can't figure out how to add conditions or variables to > > the relationship declairation. > > > > For example, > > class Product extends AppModel { > > var $hasAndBelongsToMany = array('Rebate' => array('className' => > > 'Rebate', 'condition' => 'Rebate.expires >= ' . date('Y-m-d'))); > > > > } > > > > Obviously the above doesn't work because you can't use a variable in > > another variables declaration. > > I suppose I could change it to 'Rebate.expires > NOW()' but this type > > of question comes up often such as adding the condition that a model > > has > > "is_active = 1", or > > "date > $start AND date < $end" > > ... or something similar. > > > > So how can association relationships include conditionals or variables > > if I want to keep the association in the model? > > Thanks > > John > > > > > -- jon bennett t: +44 (0) 1225 341 039 w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
