Answer the question
In order to leave comments, you need to log in
How to make EXISTS in a repository?
Guys tell me please, I want to check that the table just has an entry
something like
SELECT EXISTS(SELECT id FROM table WHERE telegam_id = 1123 and telegram_login=1 )
private function isLoginTelegram(int $telegram_id):bool
{
//$qb->expr()->exists($sub->getDQL()
$sub = $this->createQueryBuilder('u')
->andWhere('u.telegam_id = :telegram_id')
->andWhere('u.telegram_login = 1')
->setParameter('telegram_id', $telegram_id)
->getDQL();
//$this->createQueryBuilder('u')->
}
Answer the question
In order to leave comments, you need to log in
In general, I was prompted in moments:
Run your query directly and use Query#getSingleScalarResult(). If id is returned - there is a record, if NoResultException is thrown - then there is no record.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question