Re: Selecting records that have hasmany child records.

2010-01-09 Thread #2Will
Hi Everyone, thanks very much for the replies. The sub query is the only one that worked for me. I have the acts as containable statement in my app_model. I think i need to move the condition statement out of contains and into the main contains statement to limit the venue selection to venues

Re: Selecting records that have hasmany child records.

2010-01-09 Thread John Andersen
Just for curiosity, have you tried retrieving the data from the other end of the relationship - from the Offer side? $this-Offer-find( 'all', array( 'contain' = array('Venue'), 'conditions' = array('Offer.end_date ' = $time) ) ); Use $this-Venue-Offer-find( if you are in the

Re: Selecting records that have hasmany child records.

2010-01-04 Thread #2Will
Ok, I tried again at a bit of self rescue, and after a bit of reading thought contain might be able to help. $venues_contained = $this-Venue-find('all', array('contain'=array ('Offer' = array( 'conditions' = array(Offer.date_end $time) ; That of course dosn't

Re: Selecting records that have hasmany child records.

2010-01-04 Thread Jon Bennett
hi Will, Ok,  I tried again at a bit of self rescue, and after a bit of reading thought contain might be able to help. Have you included the containable behaviour in your app_model? var $actsAs = array('Containable'); $venues_contained = $this-Venue-find('all', array('contain'=array

RE: Selecting records that have hasmany child records.

2010-01-04 Thread Dave
: January-04-10 10:40 PM To: CakePHP Subject: Re: Selecting records that have hasmany child records. Ok, I tried again at a bit of self rescue, and after a bit of reading thought contain might be able to help. $venues_contained = $this-Venue-find('all', array('contain'=array ('Offer' = array

Re: Selecting records that have hasmany child records.

2010-01-04 Thread Hazem Mohamed
You can use sub-queries to solve this problem something like $venues_contained = $this-Venue-find('all', array('conditions' = array(Venue.id in (SELECT DISTINCT Offer.venue_id FROM offers as Offer WHERE Offer.date_end '$time'; But you will need to check and filter time if it is a user

Selecting records that have hasmany child records.

2010-01-02 Thread #2Will
I'm using cake 1.2. I have a table of venues (Venue model) that hasmany offers (Offer model). var $hasMany = array( 'Offer' = array( 'className' = 'Offer', 'foreignKey' = 'venue_id', ...etc How can i only select venues that have