¿Qué tiene de malo esta condición de búsqueda?

The following works, it gives me all data where deleted is null:

$conditions = array('OR' => array(

    'Task.deleted' => null,


    )

);


$this->set('tasks', $this->Task->find('all', array('recursive' => 2, 'conditions' => $conditions)));

Similiar the following gives me all data where deleted is 0

$conditions = array('OR' => array(

 'Task.deleted' => 0,


)

); //...

But If i combine it like the following, it gives me the data where deleted is null, but not where deleted is 0.

$conditions = array('OR' => array(

        'Task.deleted' => 0,
        'Task.deleted' => null

        )

);

preguntado el 31 de julio de 12 a las 15:07

Don't know this standard but it looks that you are overwriting 0 con null here. Check if 'Task.deleted' => (0, null) works ( or something like that ) -

This only gives me back the data where deleted is 0 -

2 Respuestas

You are trying to set the PHP array key 'Task.deleted' twice, overwriting it. Do either of the following:

'Task.deleted' => array(0, null)

o bien:

'OR' => array(
    array('Task.deleted' => 0),
    array('Task.deleted' => null)
)

Respondido 31 Jul 12, 15:07

Lee esto

http://book.cakephp.org/1.3/view/1030/Complex-Find-Conditions

or

$conditions = array(
    'OR' => array(
       array('Task.deleted' => 0),
      array('Task.deleted' => null)
    )
    );

$this->set('tasks', $this->Task->find('all', array('recursive' => 2, 'conditions' => $conditions)));

Respondido 31 Jul 12, 15:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.