Assuming you don't just want to do this:

$this->Article->findAll(array('Article.publishdate' => "BETWEEN
'2007-01-01 15:00' AND '2007-08-08 15:00'"));

You can do this:

$this->Article->findAll(array(
        array('Article.publishdate' => '2007-01-01 15:00'),
        array('Article.publishdate' => '2007-08-08 15:00')
));

If you've got a lot of conditions it might be good to build them up
first:

$conditions = array();
$conditions[] = array('Article.publishdate' => '> 2007-01-01 15:00');
$conditions[] = array('Article.publishdate' => '< 2007-08-08 15:00');
$conditions = array(
  'or' => array(
    array('Article.always_find_this_one' => 1),
    $conditions
  )
);

$this->Article->findAll($conditions);

On Oct 18, 12:58 pm, gafuser <[EMAIL PROTECTED]> wrote:
> Hi,
> Are there a way to use the same field multiple times in
> arrayconditions?
> The problem is that you have to use the same arraykey again which of
> course is impossible.
>
> An example is when I want to get all articles between two given dates
> like this.
>
> $this->Article->findAll(array(
>         'Article.publishdate' => '> 2007-01-01 15:00',
>         'Article.publishdate' => '< 2007-08-08 15:00'
> ));
>
> The second condition will overwrite the first. A dirty hack to make it
> work is insert af space after one of the arraykeys. Like this:
> $this->Article->findAll(array(
>         'Article.publishdate' => '> 2007-01-01 15:00',
>         'Article.publishdate ' => '< 2007-08-08 15:00'
> ));
>
> But that is really ugly and there is no way(that I know of) to make
> the formhelper do it.
>
> Thanks.


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