Almost there, the operators go in the array index, not the value.

return $this->find('all',array(

    'conditions'=>array(

         'DATE(Post.date) >'=> $date,
         'DATE(Post.date) <'=> $end_date

)));

On Oct 6, 8:52 am, "[email protected]" <[email protected]>
wrote:
> I am learning cake using a book, which has been great so far, but I am
> having problems with one example of the book when it uses the "greater
> than" and similar operators in a query...
>
> here's what the books says:
>
> return $this->find('all',array(
>
>     'conditions'=>array(
>
>          'DATE(Post.date)'=> '>'.$date,
>          'DATE(Post.date)'=>'<'.$end_date
>
> )));
>
> here's what cake will query:
>
> SELECT `Post`.`id`, `Post`.`name`, `Post`.`date`, `Post`.`content`,
> `Post`.`user_id`, `User`.`id`, `User`.`name`, `User`.`email`,
> `User`.`firstname`, `User`.`lastname` FROM `posts` AS `Post` LEFT JOIN
> `users` AS `User` ON (`Post`.`user_id` = `User`.`id`) WHERE DATE
> (`Post`.`date`) = ' < 2009-12-31 23:59:59'
>
> You can see at the end of the query that cake doesn't recognize the
> "<" or the ">" operators... so it just adds the "=" and then the "<"
> as a string. I am using the latest cake version.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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