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
0answers
8 views

Using Symfony Doctrine Migrations with Gitlab CI: GitLab CI interprets “Nothing to migrate” as error

We are using the Doctrine migrations bundle for update database in our deployment process. Currently, we are switching to Gitlab-CI. The problem: The CI is aborting the deployment process because the ...
0
votes
0answers
35 views

Symfony 4 forms use existing model

I have a Symfony entity and simple form. I want to use existing object from database instead of creating one: Entity: class Section { /** * @var integer|null * @ORM\Id() * @ORM\...
1
vote
0answers
31 views

Symfony 4 worker using doctrine not working properly : SQLSTATE[HY000] [2002] Connection timed out

I'm using a worker with the symfony 4 messenger component. This worker is receiving a message (from rabbitMQ) launch ffmpeg do a treatment on a video and save something in a database. To configure ...
0
votes
1answer
27 views

How to fully reset doctrine for performance

I have a Symfony application with Doctrine. I need to create a command that will iterate through several thousands of records from the database, retrieving related data and processing it. As ...
1
vote
1answer
24 views

How to make a query builder that find Properties based on Request

I have a estate web app in symfony4 and I have db sql structure : tables(Requests - any client can request to buy a property, Properties - the actual buildings, Fields - the dynamic field type used ...
2
votes
1answer
25 views

How to select a group of entities according to a condition in a related OneToMany association?

I'm using Symfony4 and I have two entities User and Car. A Car has a field isRent which is of type bool and further a database column user_id for the relation. class User { /** * @var ...
0
votes
0answers
22 views

How to add doctrine entity manager programmatically from controller?

I have a controller method where i added doctrine connection and doctrine entity manager programmatically to the config.yml. When i try to get the entity manager i just added via $doctrine->...
0
votes
1answer
29 views

Symfony 4.3 Doctrine Migration issue

I'm having an issue with the doctrine:migrations:migrate. I ran a version called " 20190819021520" a few days ago and worked just fine. Database was updated and had no issues. Today I'm trying to do ...
0
votes
0answers
9 views

Doctrine2 - How to define table prefix for orm mapping [duplicate]

I have a question regarding doctrine2 mapping configuration. I need to store in my database 2 logicaly separated sets of data, so I wanted to have them also separated in code. I store my entities in ...
0
votes
1answer
39 views

how and where to execute custom queries in symfony 4

I am using an entity class which extends ServiceEntityRepository like this: class Sms extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::...
0
votes
2answers
31 views

Symfony 4: Returning only active records

I would like to only get records where the active indicator is true: class Question { /** * One Question has one Figure * @ORM\OneToOne(targetEntity="QuestionFigure", mappedBy="question") ...
0
votes
0answers
24 views

Multiple repositories for single entity in Doctrine [on hold]

I'm developing a PHP Webapp accessible by Website and API. I'm using Slim Framework & Doctrine ORM. The question in the title has actually already been asked here, but my question is more focused ...
0
votes
1answer
52 views

Cannot set mapped association Id during PrePersist event

I have an article entity belongs to a category entity: /** * Article * * @ORM\Table(name="articles") * @ORM\Entity(repositoryClass="App\Repository\ArticlesRepository") * @ORM\...
-1
votes
0answers
19 views

Doctrine OneToOne and SoftDeleteable (unique index problem)

I have an entity marked as @Gedmo\SoftDeleteable. Entity has a field with @OneToOne relation. However these two does not work together, because OneToOne creates its UNIQUE INDEX. I am using Postgres ...
-1
votes
3answers
44 views

Attempted to call an undefined method named “getEntityManager” of class

I'm learning symfony and I would like to have a search bar to show user with email. But I got and error Attempted to call an undefined method named "getEntityManager" of class "App\Repository\...
0
votes
1answer
18 views

How to fix “Could not resolve type of column ”id“ of class ”RelacionesBundle\Entity\Pregunta“”?

Actually I've generated two entities: -Preguntas -Areas I'm trying to do a many to many relationshio between these two entities. In my DataBase I already have 3 tables: -Pregunta (idPregunta,Titulo) ...
0
votes
1answer
15 views

How to fix “ Class” is not a valid entity or mapped super class. ? Symfony 2.8 [duplicate]

Actually I've generated my entity Ticket from console with the next command: php app/console doctrine:generate:entity And it has generated the entity correctly with the respective getters and setters. ...
2
votes
0answers
20 views

Using php Doctrine, is there any way to do a relationship through two columns with different collations?

I want to do a relationship between two columns that have two different collations. I made the relationship and when I do a join in query builder it returns: "Cannot resolve the collation conflict" ...
0
votes
1answer
29 views

How to fix “Argument 1 passed to a must be an instance of Bundle\Entity\.., instance of Doctrine\Common\Collections\ArrayCollection given”?

I'm trying to make a module where when I create a new question assign it to different areas, so I think that it should be a Many-To-Many relationship and get another table "FSA_AreasQuestions", but I ...
-2
votes
0answers
46 views

Symfony-Doctrine : Query result different between sql and doctrine [on hold]

I'm doing this sql query 'SELECT * FROM chef_equipe INNER JOIN horaire as ho ON chef_equipe.chef_equipe = ho.chef_equipe INNER JOIN poste as po ON chef_equipe.chef_equipe = po.chef_equipe ...
1
vote
4answers
66 views

Can I get a user by their username and password using Doctrine (findOneBy()) on Symfony 4?

I want to get a user by their username and password using Doctrine (findOneBy() method), on Symfony4. security: encoders: App\Entity\User: algorithm: argon2i $username= $request-&...
0
votes
0answers
11 views

Doctrine 2.6: Setting up an enum works, updating does not work

i am trying to use enums with doctrine2.6 and mysql 5.7. I followed the guide on https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/cookbook/mysql-enums.html and adding a new enum works. ...
-2
votes
1answer
55 views

Selected option not being set in EntityType field

I have a module where I can add glasses and within that module I have a class to add the available brands for these glasses. The problem I'm facing is that when I go to edit some glasses, the brand ...
-1
votes
1answer
44 views

Cannot sort One-To-Many association with Doctrine

I am following the doctrine documentation about sort association: Ordering To-Many Associations I have a category entity, it has many articles: class Category { /** * @ORM\OneToMany(...
0
votes
0answers
35 views

API Platform and/or Doctrine tries to update ALL existing entities when updating an entity with embedded relation

I have a OneToMany relation of a Checklist and it's Answers set up so consumers can update a Checklist and add Answers to it. This works fine when there are no answers in the answers table, but when ...
0
votes
0answers
32 views

Reducing unnecessary joins in Doctrine

For simplicity sake let there be 2 entities in Symfony. The first one is called Job and the second one Field (category for Job). Each job can belong to multiple fields. Job is aware of it's fields, ...
0
votes
1answer
34 views

Symfony 4 Sorting Filtered Array Collection

I am having trouble sorting a collection resulting from a one-to-many relationship that has been filtered. I have a quiz that has questions: class Quiz { /** * One quiz has many questions. This is ...
1
vote
1answer
34 views

Getting data from the database based on dropdown selection in Symfony forms

I have two Entities, First one is the Company Entity and the other one is Events Events Entity. ManyToOne(targetEntity="App\Entity\Company", inversedBy="events" On the events from I have created a ...
1
vote
0answers
46 views

How to display extra fields from a ManyToMany relation table when requesting a sub resource

I need to display the "skill" of the "drivers" of specific "cars", which comes from a relational table "Relation_Car_Driver", this field should only appear for sub-resources calls "/cars/:id/drivers" ...
0
votes
0answers
34 views

Doctrine OneToMany relationship mapping missing inversedBy [duplicate]

I am attempting to create a OneToMany relationship between two of my entities. One Customer can be a member of many Clubs. These are my entities: class Club { /** * @ORM\ManyToOne(...
0
votes
0answers
25 views

Symfony 4 - Delete Entity which have a OneToMany relation

I have two entities, the first on for the items and the second one for the tags. Every item could have just one tag but every tag could be used by several items. Now I want to delete a tag (and ...
0
votes
0answers
53 views

getting values from the database based on dropdown selection

I have implemented a dropdown list using EntityType in Symfony Forms. Upon selection of any item, I want to retrieve its other related fields(appId in this case). Obtained appId will then be used to ...
0
votes
1answer
64 views

Syntax Error - line 0, col 122: Error: Expected end of string, got 'ON'

I'm trying to use ON in my Query Builder but it returns [Syntax Error] line 0, col 122: Error: Expected end of string, got 'ON'. Code: public function filterChamados(Request $request) { $...
0
votes
0answers
34 views

How to refresh child object in doctrine

I have 2 table property and property_type property's columns: id, name, property_type_id, style, ...., status, create_at, update_at property_type's columns: id, name, status, create_at, update_at ...
-1
votes
0answers
16 views

How to access only joined subobjects?

I'm building an doctrine query with conditional join: public function findByUserWithFullJoinedData($userId) { $q = $this->createQueryBuilder('p') ->andWhere('p.owner = :userId'...
1
vote
0answers
38 views

Managing one-to-many relations / cant get any relations?

I've problem with managing my relations (just in mysql, lol! ;)) MySQL Scheme: One property can have multiple values. For example: Property id 1 => Value id 1, Value id 4 Property id 2 => Value id 1,...
0
votes
0answers
17 views

Script cache:clear returned with error code 255 Fatal error: Uncaught Error: Class 'Doctrine\Bundle\DoctrineCacheBundle\DoctrineC

I have a Symfony project that works very well locally but when I put it on the server and I make the command composer install --prefer-dist --no-interaction --no-dev --optimize-autoloader I have every ...
-2
votes
0answers
53 views

Alias field in query returning null

Am working on API platform to implement an API, am getting result in MYSQL when querying directly, in API swagger too but getting null in browser console/ frontend.The alias field 'status' is not a ...
-2
votes
3answers
39 views

Counting the number of times a specific database table entry is queried?

I need to keep track of the number of times each table entry is queried so as to ascertain their popularity and eventually sort by that value. If it makes it easier i am using symfony with the ...
2
votes
1answer
26 views

How to change the data type of a column from STRING to TEXT in ORM Symfony 4?

I have my table information defined via the annotation of the entity. So I would like to change the following column to a TEXT instead of a STRING. So I had this: /** * @ORM\Column(type="...
0
votes
0answers
39 views

Initializing association from cached entity

I've got an issue with using cached Doctrine entities in Symfony 4. When I get a saved entity from the cache, the associations are not initialised and I don't know how I can initialise them. I have a ...
1
vote
1answer
22 views

The association refers to the inverse side field which does not exist

I have two entities: TicketEntity : /** * @ORM\MappedSuperclass() */ class Ticket implements TicketInterface { const DIR_UPLOAD = 'TicketUpload'; /** * @var integer * * @...
0
votes
2answers
28 views

Attempted to call an undefined method named “getDoctrine” of class “App\Twig\AppExtension”

I am new to learning symfony4. I have a problem to use the doctrine in the twig extension. How to use the doctrine query in twig extension. please help me how to configure the service for this code ...
0
votes
0answers
15 views

Symfony 4 Cjheckbox Unable to transform value for property path “assurance”: Expected a Boolean

I have a entity field that is int(1) in the database Entity definition : class myEntity { /** * @var int|null * @ORM\Column(name="ASSURANCE", type="integer", nullable=true) */ private $assurance ;...
0
votes
1answer
23 views

Regex with doctrine “Error: Invalid PathExpression. Must be a StateFieldPathExpression.”

I have a $value variable containing "Open|Close". I would like to use a doctrine query in Symfony to get all "status" with the word "Open" or "Close". For that I try to use a regex. However, I get the ...
0
votes
2answers
51 views

how to use two entity manager for one direction in symfony 4

I'm working with multiple Entity Managers, followed Symfony doc from here, but I want to use two entity manager for one dir. It's not working properly in findAll or findOneBy query, it's showing the ...
1
vote
1answer
21 views

Doctrine orm mapping returns error Undefined index

I'm trying to write a code that maps two to entities but in the result, I get an error Undefined index: filterId So without doctrine, the query is simple SELECT * FROM filter f INNER JOIN ...
0
votes
0answers
39 views

How do I Create a ManyToOne Relationship Between a Doctrine Entity and a Custom Data Provider?

I'm currently building a web application, and went for Symfony 4 along with API Platform. I built a custom data provider in order to pull data from a XML file, for an entity. Since it's all one-way ...
0
votes
1answer
54 views

How to make like and unlike in Symfony 4?

I'm designing like and functionality in my project and I'm stuck to display the icon. User.php /** * @ORM\ManyToMany(targetEntity="App\Entity\Image", inversedBy="users") */ private $likes; public ...
2
votes
0answers
38 views

Symfony 4 > filter a list of results, the best way

I'm working on a new Symfony 4 project. I have a list of Speakers, and a list of Themes, and I have a ManyToMany relations between. class Speakers { // ... /** * @ORM\ManyToMany(...