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 }
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
Source: https://ru.stackoverflow.com/questions/948519/
All Articles
Репозиторий сущности - find()
- u_muldergetSingleScalarValue
for example. - u_mulder pm