doctrine findby magic null value

Sean picture Sean · Oct 6, 2010 · Viewed 27.5k times · Source

I'm wondering if there is anyway to use doctrine's magic method to look for null values. For instance:

Doctrine::getTable('myClass')->findByDeletedAt(null);

Essentially, I want to return all records that are not deleted. I've tried the above, but it doesn't seem to work.

Any ideas?

Answer

Daniel W. picture Daniel W. · Jan 31, 2013

Trying this gives me the error:

Catchable fatal error: Argument 1 passed to Doctrine\ORM\EntityRepository::findBy() must be an array, string given

So this works for me:

$repository->findBy(array('date_field' => null));