We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

FindBy where column valeu is null

I'm trying to fill a selectbox with projects that dont have a delivered date yet, these projects have the value in the 'delivered date' column set to the default value 'null'

I cannot seem to figure out which parameters to use the make it search for 'where value = null'

This is how it looks right now, it doesnt return anything

$project = new Select('project_id', Project::findByDeliveredDate('null'), [
      'using'      => ['id', 'name'],
      'useEmpty'   => true,
      'emptyText'  => 'Select project',
       'emptyValue' => '',
        'class'      => 'form-control select2',
]);

I also tried

    $project = new Select('project_id', $this->modelsManager->createQuery("SELECT * FROM \PhalconTime\Models\Project WHERE delivered_date != 'null'")->execute(), [
     'using'      => ['id', 'name'],
      'useEmpty'   => true,
      'emptyText'  => 'Select project',
       'emptyValue' => '',
        'class'      => 'form-control select2',
]);


12.8k
Accepted
answer
Project::find([
    'conditions'=>'delivered_date is not null'
]);


13.8k

Thanks a lot both.

Both work but i accepted corentin-begne answer because thats the solution I implemented.