mercredi 17 octobre 2018

Doctrine2 EntityManager find() method returns null

I've got a strange error, which I have no idea how to debug. This is how I load the User entity from the database:

$user = \EntityManager::getRepository('\App\Entities\Data\User')->find($user_id);

The user id is string. For some id's it returns null, even if the id is correct. What's even stranger, is that if I retrive the user by an other attribute, then I am able to find it afterwards:

$test = \EntityManager::getRepository('\App\Entities\Data\User')->findOneBy(["name"=>$user_name);
$user = \EntityManager::getRepository('\App\Entities\Data\User')->find($user_id);

I this way user is never null.

How is it possible to debug this? Am I able to somehow get the native query string, produced by the find method?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire