Category : doctrine-orm

i have a InspectionPlan Form Type which has a product EntityType field, (Products can have attributes i assign some by fixtures) however, the formtype also has a CollectionType Field for another entity called InspectionPlanSections, this uses a InspectionPlanSectionFormType which has a CollectionTypeField for an entity called InspectionPlanQuestions with a InspectionPlanQuestionFormType with allow_add’ => true and ..

Read more

I am using Symfony Doctrine Events to trigger notification after entity status update. I want it triggered on postUpdate() of existing entity. I have defined constants of the selected status and want it recognized before message is triggered. const TRIAL = ‘trial’; const PAID = ‘paid’; const DELETED = ‘deleted’; public function postUpdate(LifecycleEventArgs $args) { ..

Read more

I’m using Symfony EntitType to display a list of options from my database. The bit of code is this : use SymfonyBridgeDoctrineFormTypeEntityType; … ->add( ‘defaultProduct’, EntityType::class, array( ‘class’ => ‘AppEntityProductProduct’, ‘label’ => ‘Product’, ’empty_data’ => null, ‘required’ => false, ‘choice_label’ => ‘name’, ‘help’ => "The product", ) ) This works fine and displays an option ..

Read more

public function getArtistsScreen(array $filters) { $qb = $this->getEntityManager()->createQueryBuilder(‘ap’); $qb->select(‘ap’)->from(ArtistProfile::class, ‘ap’); $qb->select("apc18.name , GROUP_CONCAT( ap.id, ‘|’, usr.firstName, ‘|’, usr.lastName, ‘|’, cat.id, ‘|’, ap.averageRating, ‘|’, ap.weekdayHourlyRate, ‘|’, ap.countTotalComments, ‘|’, usr.avatar, ‘|’, apc18.name SEPARATOR ‘;’ ) as artists") ->join(‘ap.user’, ‘usr’) ->join(‘ap.category’, ‘cat’) ->leftJoin(ArtistProfileCategoryI18N::class, ‘apc18’, Join::WITH, ‘cat.id = apc18.artistProfileCategory’) ->where($qb->expr()->in(‘ap.category’, ‘:category’))->setParameter(‘category’, $filters[‘category’]) ->andWhere(‘ap.status =:status’)->setParameter(‘status’,’a’) ->orderBy(‘ap.id’, ‘DESC’) ->setFirstResult(0) ->setMaxResults(1); $data ..

Read more

What’s the difference in using: getScalarResult() and getArrayResult() when running a query with QueryBuilder in Doctrine: $query = $this->em->createQueryBuilder(); $query->select(self::SHORT_LIST) ->from(DataSetting::class, ‘ds’) ->andWhere(‘ds.’.$field.’ LIKE :searchField’) ->setParameter(‘searchField’, $value . ‘%’) ->setMaxResults($filters->getLength()); $query->getQuery()->getScalarResult() and $query->getQuery()->getArrayResult() Source: Symfony..

Read more

Symfony serializer lost collection object while denormalizing. Example: We have some entity with collection in the property (I’m using Doctrine ArrayCollection but it is reproduced for any Collection which implement PHP Iterator interface) Let’s serialize and deserialize it with Symfony and JMS serializer and compare results: Origin: ^ AppEntityEntity^ {#195 -rewardItems: DoctrineCommonCollectionsArrayCollection^ {#179 -elements: array:2 ..

Read more