Symfony Relation Entity

[Solved] Symfony Relation Entity | Php - Code Explorer | yomemimo.com
Question : symfony relation entity

Answered by : murat-akmak

// src/Repository/ProductRepository.php
// ...
class ProductRepository extends ServiceEntityRepository
{ public function findOneByIdJoinedToCategory(int $productId): ?Product { $entityManager = $this->getEntityManager(); $query = $entityManager->createQuery( 'SELECT p, c FROM App\Entity\Product p INNER JOIN p.category c WHERE p.id = :id' )->setParameter('id', $productId); return $query->getOneOrNullResult(); }
}

Source : https://symfony.com/doc/current/doctrine/associations.html#joining-related-records | Last Update : Thu, 13 Oct 22

Answers related to symfony relation entity

Code Explorer Popular Question For Php