That works, thank you very much!

jeroen

On Feb 7, 3:28 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Funny, I just did something similar to this yesterday :)
>
> // used because i had multiple conditions.
> $conditions = array();
>
> // if you're using DATETIME like the created and updated fields do,
> you
> // should even be able to leave off the H:m:s if time is irrelevant
> $conditions[] = "`Course`.`date` > " . "'" . date( 'Y-m-d H:m:s' ) .
> "'";
>
> $this->set('courses', $this->Course->findAll($conditions));
>
> And if you want, say, the last 7 days, you can use strtotime() to
> provide different date ranges.  I make no claims as to speed, but it
> "works for me".
>
> There is more information in the manual under "Complex Find
> Conditions" here:http://manual.cakephp.org/chapter/models
>
> Best of luck,
> Ralph
>
> On Feb 6, 4:10 pm, "jeroen" <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I'm pretty new to cakephp, so the answer is probably pretty obvious,
> > but I'm struggling on this for too long now...
>
> > One of my models (say 'Course') has a date field, and in the index()
> > method where I would like to pass only those records which have a date
>
> > > 'now'.
>
> > However I have no idea how to define such a constraint. From what I
> > found by googling around, I assembled the following, but it does not
> > work (no records selected):
>
> >         function index() {
> >                 $constraint['Course.date'] = ' > '. date('Y-m-d H:i') ';
> >                 $this->set('courses', $this->Course->findAll($constraint));
> >                 }
>
> > I'm using 1.1.13.4450
>
> > Any hints are appreciated,
> > jeroen


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

Reply via email to