phpcomposeryggdrasilbittorrentjs-lessalt-websymfonysphinxcatalogtorrentmagnetwikidistributedsocial-networkfederatedsqlitetracker
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.2 KiB
43 lines
1.2 KiB
<?php |
|
|
|
namespace App\Repository; |
|
|
|
use App\Entity\User; |
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
|
use Doctrine\Persistence\ManagerRegistry; |
|
|
|
/** |
|
* @extends ServiceEntityRepository<User> |
|
* |
|
* @method User|null find($id, $lockMode = null, $lockVersion = null) |
|
* @method User|null findOneBy(array $criteria, array $orderBy = null) |
|
* @method User[] findAll() |
|
* @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
|
*/ |
|
class UserRepository extends ServiceEntityRepository |
|
{ |
|
public function __construct(ManagerRegistry $registry) |
|
{ |
|
parent::__construct($registry, User::class); |
|
} |
|
|
|
public function findOneByIdField(int $id): ?User |
|
{ |
|
return $this->createQueryBuilder('u') |
|
->where('u.id = :id') |
|
->setParameter('id', $id) |
|
->getQuery() |
|
->getOneOrNullResult() |
|
; |
|
} |
|
|
|
public function findOneByAddressField(string $address): ?User |
|
{ |
|
return $this->createQueryBuilder('u') |
|
->where('u.address = :address') |
|
->setParameter('address', $address) |
|
->getQuery() |
|
->getOneOrNullResult() |
|
; |
|
} |
|
}
|
|
|