I played with this for a bit and ended up using bindModel anyway. Yes,
it is good practice to keep the associations in the model, but
sometimes you need to 'override' the logic. So, I have the general
associations in the models, and then use bindModel in my controller
actions when I want something more 'specific'.
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
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---