Category : doctrine

php bin/console doctrine:fixtures:load Careful, database "DoctorHelp" will be purged. Do you want to continue? (yes/no) [no]: y purging database loading AppDataFixturesAppFixtures loading AppDataFixturesArticleFixtures In Lorem.php line 95: join(): Argument #2 ($array) must be of type ?array, string given doctrine:fixtures:load [–append] [–group GROUP] [–em EM] [–purger PURGER] [–purge-exclusions PURGE-EXCLUSIONS] [–shard SHARD] [–purge-with-truncate] Source: Symfony..

Read more

in my symfony project i have a function that shows a list of users based on their "roles" here’s the controller code /** * @Route("/admin", name="admin_index", methods={"GET"}) */ public function index(): Response { $Admins=$this->getDoctrine()->getRepository(User::class)->findBy([‘roles’ => array(‘["ROLE_ADMIN"]’)]); return $this->render(‘back/admin/index.html.twig’, [ ‘admins’ => $Admins, ]); } and here’s the render <table class="table" > <thead> <tr> <th>Id</th> <th>Nom</th> ..

Read more

In Sylius, translatable entities use an ArrayCollection to handle translations, for example Product entity has ProductTranslation entities in translations attribute. Given an already hydrated entity $object from the database we have one item in $object->translations. Now, I want to add another existing translation into my $object from the database. $qb = $this->createQueryBuilder(‘o’); $qb ->addSelect(‘fallback_translation’) ->innerJoin( ..

Read more

I am trying to figure out how to count instalments attached to the contract and then return it in the result if there are less than 2. ->select(‘cc’) ->addSelect(‘COUNT(cci) AS HIDDEN numberOfInstalments’) ->from(‘AppBundle:ClientContract’, ‘cc’) ->innerJoin(‘AppBundle:ClientContractInstalment’, ‘cci’, ‘WITH’, ‘cci.clientContract = cc’) ->andHaving(‘numberOfInstalments < :numberOfRequiredInstalments'( ->setParameter(‘numberOfRequiredInstalments’, 2) ->getResult() The code from above works well when I add ..

Read more

I have a method in Doctrine repository to search a person like this: function search($value) { $qb = $this->createQueryBuilder(‘p’); $qb->where($qb->expr()->like( ‘LOWER(p.lastName)’, "’%" . mb_strtolower($value) . "%’")); } Example: No Name Last name 1 Luis Sanchez 2 David Sánchez When I use this method and the input is ‘Sanchez’ only returns record No. 1, and if ..

Read more