Created
December 7, 2019 15:52
-
-
Save theodesp/064016e622ed45017827fe8122924d96 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Repository; | |
use App\Entity\Product; | |
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | |
use Symfony\Bridge\Doctrine\RegistryInterface; | |
/** | |
* @method Product|null find($id, $lockMode = null, $lockVersion = null) | |
* @method Product|null findOneBy(array $criteria, array $orderBy = null) | |
* @method Product[] findAll() | |
* @method Product[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |
*/ | |
class ProductRepository extends ServiceEntityRepository | |
{ | |
public function __construct(RegistryInterface $registry) | |
{ | |
parent::__construct($registry, Product::class); | |
} | |
/** | |
* @return Product[] Returns an array of Product objects | |
*/ | |
/* | |
public function findByExampleField($value) | |
{ | |
return $this->createQueryBuilder('p') | |
->andWhere('p.exampleField = :val') | |
->setParameter('val', $value) | |
->orderBy('p.id', 'ASC') | |
->setMaxResults(10) | |
->getQuery() | |
->getResult() | |
; | |
} | |
*/ | |
/* | |
public function findOneBySomeField($value): ?Product | |
{ | |
return $this->createQueryBuilder('p') | |
->andWhere('p.exampleField = :val') | |
->setParameter('val', $value) | |
->getQuery() | |
->getOneOrNullResult() | |
; | |
} | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment