Questions tagged [doctrine]

The Doctrine Project encompasses a range of innovative open source libraries and utilities designed to facilitate efficient database abstraction and Object-Relational Mapping in PHP.

The datatype of an array in a Doctrine model

I am relatively new to using Doctrine, particularly when it comes to creating a MongoDb Model/Collection. I have a field called languages that needs to be an array structured like this: $var = [ array("fname"=>"test","lname"=>"test"), ...

Retrieving an entity by its ID from various entities in Symfony2

Imagine we have a collection of entities: $entities = $em->getRepository('MyBundle:Entity')->findBy(array('cat' => 1)); What is the most efficient way to retrieve a single entity from this collection by its ID? While iteratin ...

Passing Controller Parameters to Symfony2 FormType

Working with Symfony2, I have a requirement to pass a parameter from the Controller to the FormType. Here is my Action snippet: public function addAction(Request $request) { $employee = $this->getUser(); if (null === $employee) { ...

Troubleshooting: Symfony Entity Failing to Save in Database during Persist Operation

This code functions properly when used in controllers, but it encounters issues when injected into a command. public function execute(InputInterface $input, OutputInterface $output) { $em = $this->getDoctrine()->getManager(); try { $t ...

Unable to locate any services for fixtures to load

This question has been asked multiple times before: Symfony 3.4 and Fixtures Bundle issue with bundle version 3.0 Symfony 3.4.0 Could not find any fixture services to load Symfony Doctrine can't find fixtures to load Could not find any fixture servi ...

Relationship mapping for a singular inheritance entity using a one-to-many association

I am encountering an issue with the single table inheritance mapping for Doctrine ORM, also known as STI. It appears that having a one-to-many association from the STI entity to another entity is not possible. I have two entities named Customer and Suppl ...

Utilize several conditions in Doctrine Query Language for enhanced querying capabilities

In my database, there is a column named "refused" which can have values of 0, 1, or NULL. I am trying to retrieve rows that only have values of 0 and NULL. My attempt so far has been using the following code: ->andWhere('b.refused IS NULL') While th ...

Oh no, Symfony 2.6 is throwing a Doctrine ORMException: The EntityManager has been shut down

Currently, I am in the process of importing users from an excel file. To manage this task effectively, I have established an entity manager: $em = $this->getDoctrine()->getManager(); Here is a snippet of the loop I am using for this operation: .. ...

The implementation of an interface by a Doctrine ORM entity

Having an issue in my current project with the TaggableInterface. This interface includes methods for adding, deleting, and retrieving tags. interface TaggableInterface { public function addTag(TagInterface $tag); public function deleteTag(TagInterf ...

Symphony 5.0.* no longer includes the ArrayCache component

I'm encountering a problem that I can't seem to resolve. Ever since updating my dependencies, I've been facing an error related to the ArrayCache in Doctrine. An issue arises at ContainerBuilder.php line 1103: The class "DoctrineCommonCacheArr ...

What is the process for testing a personalized DQL function?

After following a tutorial, I developed my own custom DQL function. Now I want to write tests for it, but the intricacies of DQL make it challenging. Is there a method available for testing DQL functions? It seems that even the Doctrine project itself do ...

Issue with custom annotations in Symfony 4: @ORMEntity not recognized

While working on the development of my CMS, I encountered a specific issue that I need assistance with. The error message I am facing is as follows: [Semantical Error] The annotation "@Doctrine\ORM\Mapping\Entity" in class ScyLabs\G ...

What exactly does the Doctrine query builder serve to accomplish?

What are the benefits of using Doctrine to construct queries like this: <?php // $qb instanceof QueryBuilder $qb->select('u') ->from('User u') ->where('u.id = :identifier') ->orderBy('u.name ASC& ...

Capturing information from a form containing various elements for storage

After following the instructions provided in https://symfony.com/doc/current/form/embedded.html, I encountered an issue when trying to submit a form containing three entities - Patient, PatientSample, and PatientOrder. The error message stating that patien ...

Guide for integrating the logic of editAction into showAction within Symfony 2 Doctrine generated CRUD

I have a Symfony 2 project where I've used Doctrine to generate CRUD's for certain entities in my database. Specifically, I have entities named TariffMc and TariffMcServiceMcRelation. A single TariffMc entity can be associated with multiple TariffMcService ...

Is it possible to have nested associations within Shopware 6?

Within my EntityDefinition, there is an association: ... class ParentEntityDefinition extends EntityDefinition { ... protected function defineFields(): FieldCollection { return new FieldCollection([ (new OneToOn ...

Creating dynamic date fields in Symfony/Doctrine is a valuable skill to have. Here's a step-by

Managing a user database involves storing user information such as name, age, and address. However, one crucial field in the database is created_at, which records the registration time of the user. In traditional PHP code, this can be achieved using: INSE ...

You're in need of a "cli-config.php" or "config/cli-config.php" file within your project in order to operate the Doctrine ORM with Silex via the command line

I've been attempting to integrate Doctrine ORM with Silex, but I'm encountering a frustrating challenge due to the inconsistent documentation provided. Upon running vendor/bin/doctrine in the console, the following message is displayed: output: ...

Issue with the Doctrine mapped field functionality has arisen

I am facing an issue with fetching notifications for a user entity, specifically UserUser and MiscNotification. I want to be able to retrieve the user's notifications within the User entity by using $user->getNotifications(). Normally, I don't encount ...

The persistent struggle with Symfony2 DB2 doctrine: Creation of the database failed

When attempting to create my database structure in DB2 using Doctrine, I encountered the following response: >php app/console doctrine:database:create Could not create database "monng" for connection named default Notice: Undefined index: dbname Howev ...

Creating an event listener that can detect changes to a specific field before or during a save action

I am facing a challenge in updating specific fields during a save operation, but only when one particular field is being modified. I'm unsure of how to achieve this. Additional information: If a user is editing the 'is_activated' field in m ...

Is there a way to define a varying number of OR conditions in a Doctrine SQL Where clause?

Is there a way to dynamically generate a Doctrine ORM query that mimics the following SQL statement, considering that the number of values in the 'OR' clause may vary with each execution? SELECT * FROM table1 WHERE table1.group = 1 OR 2 OR 3 For in ...

What is the best way to showcase the elements in my ArrayCollection while utilizing joined tables and ManyToMany relations?

Within my entity, I have a field named linkedDocuments: class Documents { /** * @ORM\ManyToMany(targetEntity="App\Entity\Documents") * @ORM\JoinTable(name="documents_documents", * joinColumns={@JoinColumn(name="link_origi ...