Re: Model : Find : Conditions not working properly?

2008-11-10 Thread Gwoo


> Current Code::
> return $this->find(
> 'all',
> array(
> 'conditions'=>array(
> 'DATE(Post.date)' => '>= '.$date,
> 'DATE(Post.date) '=> '<= '.$end_date
> )
> )
> );
>
> Debug SQL Output::
> WHERE DATE(`Post`.`date`) = '<= 2008-12-31 23:59:59'
>
> Expected SQL Output::
> WHERE DATE(`Post`.`date`) >= '2008-01-01 00:00:00' AND
> DATE(`Post`.`date`) <= '2008-12-31 23:59:59'
>
> What am I doing wrong that is causing this to fail?
>

since you are using the same key twice it is being overwritten. you
need to use array('AND' => array(
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Model : Find : Conditions not working properly?

2008-11-10 Thread validkeys

this should do it

> Current Code::
> return $this->find(
> 'all',
> array(
> 'conditions'=>array(
> 'DATE(Post.date) >=' => $date,
> 'DATE(Post.date) <='=> $end_date
> )
> )
> );
>


On Nov 10, 6:07 pm, apipkin <[EMAIL PROTECTED]> wrote:
> I am having a problem with using the Conditions parameter in the
> Model::Find object. I am reading a book Beginning CakePHP: From Novice
> to Professional (ISBN 9871430209775) and there is a Blog application
> similar to the one in the Cake Tutorials. The code seems to be written
> correctly according to the instructions in the book.
>
> Current Code::
>                 return $this->find(
>                         'all',
>                         array(
>                                 'conditions'=>array(
>                                         'DATE(Post.date)' => '>= '.$date,
>                                         'DATE(Post.date) '=> '<= '.$end_date
>                                 )
>                         )
>                 );
>
> Debug SQL Output::
> WHERE DATE(`Post`.`date`) = '<= 2008-12-31 23:59:59'
>
> Expected SQL Output::
> WHERE DATE(`Post`.`date`) >= '2008-01-01 00:00:00' AND
> DATE(`Post`.`date`) <= '2008-12-31 23:59:59'
>
> What am I doing wrong that is causing this to fail?
>
> Thanks in advance!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---