src/Repository/TextLoiRepository.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Repository;
  3. use App\Entity\Societe;
  4. use App\Entity\TextLoi;
  5. use Doctrine\Persistence\ManagerRegistry;
  6. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  7. /**
  8.  * @method TextLoi|null find($id, $lockMode = null, $lockVersion = null)
  9.  * @method TextLoi|null findOneBy(array $criteria, array $orderBy = null)
  10.  * @method TextLoi[]    findAll()
  11.  * @method TextLoi[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  12.  */
  13. class TextLoiRepository extends ServiceEntityRepository
  14. {
  15.     public function __construct(ManagerRegistry $registry)
  16.     {
  17.         parent::__construct($registryTextLoi::class);
  18.     }
  19.     /**
  20.      * @method integer countTextLoi
  21.      */
  22.     public function countTextLoi() 
  23.     {
  24.         $entityManager $this->getEntityManager();
  25.         $query $entityManager->createQuery(
  26.             'SELECT count(t)
  27.             FROM App\Entity\TextLoi t'
  28.         );
  29.         // returns an array of Product objects
  30.         return $query->getSingleScalarResult();
  31.     }
  32.     /*************************************************************************/
  33.     // /**
  34.     //  * @return TextLoi[] Returns an array of TextLoi objects
  35.     //  */
  36.     // 
  37.     /*
  38.     public function test($soc)
  39.     {
  40.         return $this->createQueryBuilder('t')
  41.             ->andWhere('t.exampleField = :val')
  42.             ->setParameter('val', $value)
  43.             ->orderBy('t.id', 'ASC')
  44.             ->setMaxResults(10)
  45.             ->getQuery()
  46.             ->getResult()
  47.         ;
  48.     }*/
  49.     /**
  50.      * @method array countText
  51.      */
  52.     public function listeTextLois(Societe $societe): array
  53.     {
  54.         //$entityManager = $this->getEntityManager();
  55.         $conn $this->getEntityManager()->getConnection();
  56.         $sql "SELECT text_loi.id as id1,sl.id as id2
  57.                 FROM text_loi  
  58.                 LEFT OUTER JOIN (SELECT * 
  59.                                  FROM text_societe 
  60.                                  WHERE text_societe.societe_id=:s) sl 
  61.                 ON text_loi.id = sl.text_loi_id 
  62.             ";
  63.         $stmt $conn->prepare($sql);
  64.         $stmt->execute(['s' => $societe->getId()]);
  65.         //dd($stmt->fetchAllAssociative());
  66.         // returns an array of arrays (i.e. a raw data set)
  67.         return $stmt->fetchAllAssociative();
  68.     }
  69.     /*
  70.     public function findOneBySomeField($value): ?TextLoi
  71.     {
  72.         return $this->createQueryBuilder('t')
  73.             ->andWhere('t.exampleField = :val')
  74.             ->setParameter('val', $value)
  75.             ->getQuery()
  76.             ->getOneOrNullResult()
  77.         ;
  78.     }
  79.     */
  80. }