Does symfony / doctrine have a ready-made tool that returns a boolean value about the presence of an identifier in the table? Well type:

if($somevar->checkExists($id)) { //to do } 
  • Репозиторий сущности - find() - u_mulder
  • @u_mulder I’m doing this, it’s just as a matter of fact this object creates what to check. I thought there is something less resource intensive. - Winteriscoming
  • one
    Well, if only in the repository to write your own method that returns getSingleScalarValue for example. - u_mulder pm

1 answer 1

You can check the number of entries by criteria:

 <?php // Check there is no user with nickname $availableNickname = 0 === $em->getRepository('MyProject\Domain\User')->count(['nickname' => 'nonexistent']); 

If the count is greater than zero, then the record is present documentation