Trips hasMany Legs
I'm trying to find only trips that have a certain destination. I have consulted the following question: In cakephp how can I do a find with conditions on a related field? ad infinitum to no avail.
I get: "Query failed: ERROR: missing FROM-clause entry for table "Leg" LINE 1: ...p__origin_airport" FROM "trips" AS "Trip" WHERE "Leg"."des..."; and,
"SQL Error: ERROR: missing FROM-clause entry for table "Leg" LINE 1: ...p__origin_airport" FROM "trips" AS "Trip"
I have tried setting up the find in all of the ways suggested in the above question and can't seem to figure this out. It's to the point where I'm beginning to think there's some other problem. Can someone help me with finding a certain model's results by a hasMany model's conditions?
Below is the version of the find that throws the above code. The other versions of the find() all return similar pg.query errors (no from clause)
Thanks!
$this->find('first', array('conditions'=>array('Leg.destination'=>'XXX'),'contain'=>array('Leg') ,
'order'=>'Trip.price ASC'));