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
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
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
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
: 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
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
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