I’m working on a system which uses doctrine/orm 2.6 (PHP 7.1 & MySQL 5.7) and am trying to update a large number of entities using the following code: The issue I’m running into is that the entities have lots of lifecycle events registered (preUpdate, prePersist, postUpdate, postPersist), and some of these events involve expensive operations which aren’t necessary when doing
Tag: doctrine
When a decimal column is mapped to a typehinted float property, doctrine updates a field even if not changed
I have a User class, with the field Or with php8, same behavior: If I load a user, even without changing anything, at the next flush(), doctrine will send a query to update its credit: (This is very dangerous because the credit may have been changed in the meanwhile by another script, reverting the change. The credit isn’t supposed to
New alternative for getDoctrine() in Symfony 5.4 and up
As my IDE points out, the AbstractController::getDoctrine() method is now deprecated. I haven’t found any reference for this deprecation neither in the official documentation nor in the Github changelog. What is the new alternative or workaround for this shortcut? Answer As mentioned here: Instead of using those shortcuts, inject the related services in the constructor or the controller methods. You
Error: Expected Literal, got ‘*’ in Doctrine
I want to retrieve the number of rows in my courrier table. In my fixtures, I have these lines : I have these mistakes when I do symfony console doctrine:fixtures:load : What’s wrong with the * in my query ? Answer Doctrine expects you to use one of the fields of your entity. In SQL you don’t need to use
How to automatically trim string when persisting a Doctrine entity?
Let’s say I have this entity: My controller: I want doctrine to register the name of myEntity as awesome name and not awesome name . Is there a way to configure doctrine to do this? Answer You do not need to “configure doctrine” in any way. Just use PHP and introduce the logic in your entity: This way your data
Symfony Registering New User getUser returns null on handling request
Trying to register a new user with a form and ajax request (as it will become a modal form) and hit a snag on trying to validate the form. When the request gets handled, it states that the user is null in the password validator. And not understand how to get past this or allow this one route to allow
Symfony 3.4 – cannot load field value
I’m using Symfony 3.4.47 w/ MySQL 8 and getting a field value wasn’t a big thing until today. I’ve created a migration file to add a new field to an existing entity: And I’ve added the field ‘cliente_apelido’, getter and setter to the ‘Plano.php’ model: It turns that, when I’m trying to use the getClienteapelido() getter, it returns an empty
Symfony 5 – ManyToOne __isInitialized__: false
I try to get value from object but objects return __isInitialized__: false and null values what did I miss? twig situ dump : situ entity : event entity : category entity : Answer You just got to know the doctrine lazy loading feature. It fetches the data until you fired the getter method the first time. You could know this
Doctrine insists on trying to use PostgreSQLDriver despite contrary config
I am setting up a Symfony 5.2 app, using doctrine/doctrine-bundle 2.4 and doctrine/orm 2.9. My doctrine.yaml config file looks like this: The problem is that when I run doctrine:fixtures:load, I get the following output: It looks like Doctrine is trying to use the Postgre driver, though I have specified MySQL. Is there another place where I need to configure this?
“Error [Semantical Error] The annotation “@DoctrineORMMappingOnetoMany” in property” on Gitlab CI but not in local env or production [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed last year. Improve this question I’ve