Findby magic null value doctrine

I am wondering if in any case the doctrine magic method is used to search for null values. For instance:

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

Essentially, I want to return all records that are not deleted. I tried above, but it does not seem to work.

Any ideas?

+3
source share
4 answers

Trying this gives me an error:

Fatal error allowed: argument 1 passed to Doctrine \ ORM \ EntityRepository :: findBy () must be the array specified in the string

So this works for me:

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

In fact, I think I tried to be a fantasy. This can be done as follows:

Doctrine::getTable('myClass')->findBy('deleted_at',null);
+1
source

, , . 'deleted_at' :

Doctrine::getTable('YourClass')->findByDeleted_at($val);

, "deleted_at".

0

, , Doctrine 1.2.x

, :

Doctrine::getTable('YourClass')->findByDeleted_at(null); //he want to get NOT DELETED rows!

Doctrine : " findBy" , null ;

->findBy('deleted_at', null) .

->findBy('deleted_at','NULL') , SQL: ... WHERE deleted_at = 'NULL';

SQL :

... WHERE deleted_at IS NULL;

, ->findBySql():

Doctrine::getTable('YourClass')->findBySql('deleted_at IS NULL', array());

* Hydration_Mode.

, -...

0

Source: https://habr.com/ru/post/1768158/


All Articles