We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Selecting records where column is NULL

Hi,

I'm trying to use the ORM to select records from the database where the column value is NULL. Does anyone know how to achieve that? I've tried:

Groups::find(array( 'conditions' => 'parent_id=NULL' ));

Groups::find(array( 'conditions' => 'parent_id=?0', 'bind' => array(null) ));

Groups::find(array( 'conditions' => 'parent_id=?0', 'bind' => array(new \Phalcon\Db\RawValue('NULL')) ));

Thank You!



85.5k

if you try with parent_id IS NULL and parent_id IS NOT NULL ?

It worked perfectly! Thanks!