Questions tagged [doctrine-orm]

Doctrine ORM is a PHP ORM. While Doctrine 1.2 uses the Active Record pattern, Doctrine ORM 2 and up uses the Data Mapper pattern. The Doctrine project is a collection of open source libraries and tools for dealing with database abstraction and Object-Relational Mapping written in PHP.

Filter by
Sorted by
Tagged with
0 votes
0 answers
13 views

How to copy doctrine entity manager

Is there a way to copy an entity manager? My use case is bulk processing. From doctrine's own documentation [link]: $batchSize = 20; for ($i = 1; $i <= 10000; ++$i) { $user = new CmsUser; $...
HubertNNN's user avatar
  • 1,591
0 votes
1 answer
20 views

Doctrine Migrations with more than one databases/schemas (in Symfony project)

I have a single data connection with two schemas configured in my Symfony 6 project: Localhost - app - common <doctrine:config> <doctrine:dbal dbname="app" url="%env(...
Jazi's user avatar
  • 6,570
1 vote
0 answers
26 views

How to retrieve or update data inside Doctrine lifecycle events listener

In a Symfony4.4-based application, inside preUpdate() method of my event listener, I'm just trying to query an entity data from database using classic and known Symfony code to do so, for the sake of ...
Patrick's user avatar
  • 129
0 votes
1 answer
23 views

How to retrieve related entities using Doctrine ORM in Symfony?

Title: I have a product_link table with the following records: | id_product_link | product_link_principal | id_client | |------------------------|---------------------------------|-----...
Aymeric's user avatar
  • 347
0 votes
1 answer
38 views

HasLifecycleCallbacks dont work in symfony 6.2

#[ORM\Entity(repositoryClass: MaintenanceBateauRepository::class)] #[ORM\HasLifecycleCallbacks] class MaintenanceBateau { #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] private ?\...
user3054434's user avatar
0 votes
0 answers
15 views

Including Entity Metadata and Related Methods Without Dependency in Doctrine

I have two Doctrine entities: "Product" and "Highlight". The "Product" entity is part of the "yusrub/catalog" package, while the "Highlight" entity ...
gul's user avatar
  • 38
0 votes
1 answer
18 views

Why does Doctrine ORM preUpdate event execute endlessly when creating a notification for an Order status change in Symfony?

I have two entities in my symfony project: Order, Notification.I need create a notification when "status" field of Order was changed.I created OrderEventSubscriber which implements Doctrine\...
Shamil Hairulaev's user avatar
0 votes
1 answer
24 views

Symfony testing my command demands passing parameter to constructor. Why?

Symfony 6 Doctrine 3 phpunit My origin command is running as it should. Nothing special about it. Now I wanted to write a test case. But all I get is: Running: php bin/phpunit tests/Command/...
Juergen Schulze's user avatar
0 votes
1 answer
34 views

Symfony Form Builder with Choice Field leads to Array to string conversion error

Symfony 6 Doctrine 3 I used the make:form and make:crud commands to auto-generate everything, so I have no clue why this leads to an error. I understand the error; hence it's self-explanatory. But I ...
Juergen Schulze's user avatar
0 votes
0 answers
31 views

Edit form with inherited class: Unknown column 't0.id' - Symfony

so I'm working on a symfony project in which I'm using class inheritence: I have three main entities: ActeursLocaux-> parent class, Entreprise-> child class and Association-> child too. I ...
melione's user avatar
0 votes
0 answers
19 views

Is it possible to query with IN expression in Doctrine, with multiple InParameter as arguments?

What I'm trying to achieve is to run a query whose structure is similar to the one provided in the MySQL Docs page: https://dev.mysql.com/doc/refman/5.7/en/comparison-operators.html#operator_in SELECT ...
alexbusu's user avatar
  • 701
0 votes
1 answer
33 views

How do I stop needing to cache:clear every annotation change?

I have a fresh project from built in Symfony 5 and have Api Platform 2.7. My project also have PHP 7.4. My problem is that every change that I got in annotations, I need to input cache:clear or cache:...
MJ Convento's user avatar
0 votes
0 answers
20 views

Is it possible to set Doctrine parameter in doctrine.yaml (or doctrine.php) dynamically?

I'm using a Doctrine filter to limit the result set to the logged in user's records (ie where user_id = <their id>). I'm wondering if this can only be done adding parameters to the Doctrine ...
mark2017's user avatar
0 votes
0 answers
26 views

Problem with Doctrine 2 QueryBuilder RIGHT JOIN

I have problem with QueryBuilder, i have three tables: "counter" "cost_tp" "counter_cost_tp" (relation many to many between counter and cost_tp) In raw SQL i can create ...
Szal1k's user avatar
  • 1
0 votes
0 answers
34 views

findBy doesn't join ManyToMany relations

I have two entities: Card and Tag. Card has a property tags that is a relation ManyToMany to Tag /** * @ORM\Entity(repositoryClass=App\Repository\V2\LM\CardRepository::class) * @ORM\Table(name="...
Neo710's user avatar
  • 85
0 votes
0 answers
45 views

Symfony | Entity override

I'm coding an Symfony app composed by a core and some plugins. Each plugin is designed as a bundle and I try to create a system to enable / disable a plugin dynamically (like Wordpress). In a plugin, ...
Rubix's user avatar
  • 43
0 votes
1 answer
65 views

GeneratedValue is being generated in local dev environment, but not in the production environment on platform.sh (Symfony 6.1)

The value: #[ORM\Entity(repositoryClass: CompanyRepository::class)] class Company { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; The code: dump($company); dump($...
Roman Reimche's user avatar
0 votes
0 answers
35 views

Caching for each user

I don't fully understand how should I approach caching data for each specific user with symfony framework. I'm creating a quiz app, so each user has its own quiz, each quiz has its own category, each ...
ch3ssnut's user avatar
0 votes
0 answers
21 views

sorting order on a field ( mediaOrder ) which belongs to a pivot ( Middle ) table does not work

I want to apply sorting order on a field ( mediaOrder ) which belongs to a pivot ( Middle ) table and pivot does not have any entity because we are using ORM with below mentioned Relation. /** * @ORM\...
hassan softech's user avatar
0 votes
1 answer
38 views

Doctrine maxResult issue

I have a query with multiple inner joins and a maxResults on my query. The issue is that when I set the maxResults I also counts the results from the inner join. For example I have prediction_summary ...
foxoffire33 's user avatar
0 votes
0 answers
20 views

Symfony doctrine mongodb changing field type to object instead of array after removing a string element from array

It is more like a php issue instead of doctrine mongodb. I feel like I'm doing it wrong. So I have this Attendance data which I'm getting from db. This is how the data looks like in the db: { id: '1'...
s.khan's user avatar
  • 605
0 votes
1 answer
44 views

How to define API to query a related table before putting data

I need some advice how to structure an API endpoint. I'm using Symfony 6.2 with API Plaform 3.1. Let's say I have following 3 entities: User(id,...) APIKey(id, userId, apikey, ...) Log(id, apikeyId, ....
ninsky's user avatar
  • 1,752
0 votes
1 answer
30 views

How to select a field with condition through a persisted multi-dimensionnal array (Doctrine / Symfony 5)

I am trying to retrieve a field from my multi-dimensional array that has been persisted in database. The array looks like this: $valid = [ "technical" => [ &...
Zkimi's user avatar
  • 13
0 votes
0 answers
29 views

SQLSTATE[42S22]: Column not found: 1054 Unknown column 't9.id'

I'm on Symfony 6 and I'm trying to get my data in DB. Here is the error message I get : An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 't9.id' in ...
gd276's user avatar
  • 11
0 votes
0 answers
47 views

How can I fix addSelect subquery?

I created this sql method and I have problem with method addSelect ->addSelect("count(rf.id)/($countMyFoods) as HIDDEN orderBy") I got this error: [Syntax Error] line 0, col 24: Error: ...
Marcin Górski's user avatar
0 votes
0 answers
41 views

Symfony/Doctrine, 121 error : Duplicate key on write or update

With Symfony 5 and Doctrine, I use php bin/console d:s:u --force command for update my datbase. I don't use migrations, even though I know I ought to. Since a few days I have this error : An ...
Gaylord.P's user avatar
  • 1,509
0 votes
2 answers
131 views

How do I pass database credentials as environment variables from docker-compose to Symfony to the Doctrine yaml file?

I have a docker env set up with Symfony (5.x) & MariaDB - the docker-compose.yaml file contains the db configuration env variables. The .env.local file in the Symfony app uses the configuration ...
dbcn's user avatar
  • 199
0 votes
0 answers
36 views

Doctrine Event Subscriber causes integration tests to fail with 'There is already an active transaction' message

I have an event subscriber that looks like the following: class MySubscriber implements EventSubscriberInterface { public function __construct( private MyService $service,) { } ...
Laszlo Nagy's user avatar
0 votes
0 answers
33 views

How to create a sensible entity structure with/without inheritance using Symfony 6/Doctrine

I want to write a Symfony 6.2 application using Doctrine 2.14 for ORM. It's about managing bank account entries, different kinds of costs classes and connected information. Think of entities: "...
Andreas's user avatar
0 votes
0 answers
15 views

SonataNewsBundle config is not accepting given classes

So I have the following config part from SonataNewsBundle (whom I transfered to /src to make it work in compliance with symfony 6.2): db_driver: doctrine_orm class: post: App\Entity\Post ...
codeWanderer's user avatar
0 votes
1 answer
40 views

Having an issue when trying to persist Doctrine

I'm having an issue when trying to persist an instance of the Thos\Index class in my PHP application with Doctrine ORM. I'm receiving the following error: "Uncaught Doctrine\ORM\Mapping\...
Sergio Paniagua López's user avatar
0 votes
1 answer
45 views

symfony 6 legacy with doctrine

I am asking for your help because today I am having a legacy problem. I have a Holder class which inherits from the User class. I would like to associate a user with several holders with inheritance ...
Sofian Ghérabi's user avatar
0 votes
1 answer
45 views

No identifier/primary key specified for Entity "App\Entity\Customers". Every Entity must have an identifier/primary key

I have a class in Lumen, as I am trying to implement the doctrine, here <?php namespace App\Entity; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\...
Fil's user avatar
  • 8,135
0 votes
0 answers
31 views

Doctrine OneToMany Relation with two joins

I have the following table schema: A table where persons are stored CREATE TABLE `cdb_person` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(60) COLLATE utf8mb4_unicode_520_ci NOT NULL, `...
David Schilling's user avatar
0 votes
1 answer
58 views

doctrine not removing entity assertion constraints

I used to have a entity assertion #[ORM\Column( type: 'string', name: 'password', length: 20, nullable: false )] #[Assert\NotBlank] #[Assert\Length( max:...
Sakshi_Goraniya's user avatar
0 votes
1 answer
70 views

Modify the query that is used to get the list items after filter has been applied

We are using ULIDs in our Symfony 6 project as data type for the ID of all of our entities. The symfony/uid package helps a lot with that. To quickly build an admin interface, we are using Sonata ...
Subsurf's user avatar
  • 1,256
0 votes
0 answers
24 views

Which set of names does Doctrine's SQL Query Builder use: mapped or original (from the database)?

Although the name is SQL Query Builder, it seems to be a way to generate DQL statements, not SQL, as indicated by the note at The QueryBuilder and corroborated by this question: doctrine: QueryBuilder ...
ByteEater's user avatar
  • 737
0 votes
0 answers
41 views

trying to create an array of items but i get: cannot use object of type Entity as array

Hello please i am new to php and symfony i need help!! i am using api platform, I have an invoiceLineItems field which is an array of invoiceLineItems entity and when when setInvoiceLineItems is ...
Success Nduka's user avatar
0 votes
1 answer
18 views

What is the default for the attribute fetch in a ManyToOne annotation in Doctrine/PHP?

I have this class, using Doctrine/PHP: class Client { /** @ORM\ManyToOne(targetEntity="Fee", fetch="EAGER") @ORM\JoinColumn() */ private ?Fee $defaultFee; // [...] } ...
Mathias Bader's user avatar
0 votes
1 answer
32 views

Doctrine Extension working locally but doesn't work on the live server

I'm binding entity manager in the container like this with the configurations including the DATE extension function ....... Config::class => create(Config::class)-&...
Zuby's user avatar
  • 5
0 votes
0 answers
88 views

Doctrine lazy EntityManager

I have a class in which there is the following function: public static function get($key) { global $container; return $container->get($key); } /** * @return \Doctrine\ORM\...
Luu's user avatar
  • 7
0 votes
0 answers
24 views

Error while creating entity in Doctrine using maker bundle

I tried creating an entity using php bin/console make:entity in my symfony project. I get the following error. In AnnotationException.php line 53: [Creation Error] An error occurred while ...
sridhar pandurangiah's user avatar
0 votes
1 answer
30 views

Doctrine One-to-Many Mapping with auto generated ids

I have two classes Author and Posts. One author can have many posts and the posts table has a reference to the author by author_id. I would like to tell Doctrine to populate author_id after it obtains ...
Bacchus's user avatar
  • 515
0 votes
1 answer
55 views

The class is not uploadable. If you use attributes to configure VichUploaderBundle, you probably just forgot to add `#[Vich\\Uploadable]`

I am trying to set up uploading to an API Platform server using this documentation: https://api-platform.com/docs/core/file-upload/ However, following all of these steps gives me an error when trying ...
Brettins's user avatar
  • 822
0 votes
0 answers
40 views

how can i use syntax of php 8 in vscode?

this is my code i use symfony5 and php v8.2 class Favoris { //id #[ORM\id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id=null; } an error is defined when i declare the ...
amin amine's user avatar
0 votes
1 answer
90 views

Unexplained error message: Doctrine\ORM version 2.14.1, PHP 8.2, Doctrine\Common\Annotations\AnnotationException

I have several Entites with the annotation @ORM\HasLifeCycleCallbacks(), since I work with Doctrine ORM version 2.14.1 and PHP 8.2 I get the following message again and again: [23-Mar-2023 10:33:22 ...
Peter's user avatar
  • 1
1 vote
2 answers
120 views

Can Doctrine hydrate my entity with a custom scalar values (e.g. aggregate, CASE result, etc) out of the box?

If I have a Querybuilder instance and apply something like this: $queryBuilder->addSelect(" CASE WHEN c.modifyStamp > c.createStamp THEN 'draft' ELSE 'published' END AS ...
Mark G's user avatar
  • 73
1 vote
0 answers
64 views

Customizing a Api Platform POST Json request

the schema and json request right that api platform generated for me is wrong, the dossier entity has a relationship with the fase, type and status entity so when making a new dossier the fase, type ...
adnanebds's user avatar
0 votes
0 answers
30 views

Symfony - Doctrine : Could not resolve type of column "MENUSid" of class "App\Entity\Menus"

I am getting this error : Could not resolve type of column "MENUSid" of class "App\Entity\Menus" I'm trying to have a OneToMany relation between two entities : MENUS and FORMULA =&...
Guihome's user avatar
0 votes
1 answer
47 views

I'm using doctrine orm and I want to compare the date(only) from a datetime column in the database to user inputted date (only)datetime-local in php

I have an entity with a due-date column saving datetime. I want to confirm that the date(alone) has not been saved before. But I'm unable to compare just the dates from the datetime objects. The ...
Zuby's user avatar
  • 5

1
2 3 4 5
343