Thursday, July 29, 2010

Trouble with using a condition on a related model

Hi all,

I'm having a slight problem with querying data on an association I've
created.

The two models are Product and ProductVariation. The ProductVariation
model belongs to the Product model and the Product model hasMany
ProductVariations.

This is all well and good until I attempt to run the following query:

$this->Product->find('all', array('conditions' =>
array('ProductVariation.id' => 5)));

I get a notice saying - SQL Error: 1054: Unknown column
'ProductVariation.id' in 'where clause'

I don't understand, the models are associated and when I pull out a
single product by its ID, the ProductVariation's are retrieved as
well, but I cannot seem to get a condition bound to that column!

Any insight would be greatly appreciated.

Thanks in advance

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: