Questions tagged [doctrine]

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

Filter a doctrine ManyToMany Relationship by property of target

I have the Entity Item and the Entity Category. They are in a ManyToMany relationship. When I run getItems() on a Category I would like to filter the results by the prooperty visible (boolean). I ...
0
votes
0answers
18 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, ...
1
vote
1answer
25 views

How to add an index definition on Many-To-Many JoinTable in Doctrine?

I have two Entities and a Join table for Many-To-Many relation: Entities/Product.php namespace App\Entities; use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; /** *...
2
votes
1answer
50 views

How to create/mutation entity with sub relation on apiplatform/graphql

I want to create two entities that are related. How can I create the first entity with the required sub-entity. I've tried the following code but graphql returns the following error: { "errors": [ ...
0
votes
0answers
8 views

Doctrine QueryBuilder not working in Apigility, returning trace and 500 error

I'm trying to use Doctrine in Apigility. I followed the installation procedures and everything went well. I'm wondering how can I integrate it in my entity Resource file. For example, I have ...
1
vote
1answer
37 views

How to make Doctrine reject an entity if a property has an empty string value?

I'm trying to prevent empty string insertion into MySQL database via doctrine, I did this : /** * @ORM\Column(type="string", length=255) * @Assert\NotBlank() ( or NotNull() ) */ ...
0
votes
0answers
32 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
20 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
24 views

How to load multiple fixtures related one to each other properly?

This is my first attempt of loading multiple fixtures, most of each are related to each other. I need to enter the fixtures as without them I am not able to test if crud fields are working as ...
2
votes
1answer
82 views

Saving data from form with multiple objects

Following this guide https://symfony.com/doc/current/form/embedded.html I created a form with three entities. Patient, PatientSample and PatientOrder. When I submit the form I get an error that ...
0
votes
0answers
38 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
31 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 ...
0
votes
1answer
26 views

Having trouble making a query builder work properly for finding all posts from last 7 days

I'm using Doctrine query builder to try to find all occurrences from the last 7 days. Here's my code: return $this->createPublishedQueryBuilder('content') ->andWhere('...
0
votes
0answers
12 views

Entity field ArrayCollection, doctrine insert name class in database

I have a object with field type array, it's initialize to docrine collection, but when I save the objcet, the value inserted into my database is : O:43:"Doctrine\Common\Collections\ArrayCollection":1:...
-1
votes
0answers
21 views

Find source of autowired service in Symfony

Recently I stumbled upon a weird bug, which involved failed testcase due to a typehint of a getter of an entity not being correct. However this bug occurred in the test of the Symfony Container, ...
-2
votes
0answers
32 views

Is there any way of getting different Database Object, depending on the user's roles? [closed]

I have an application where different roles can see different scopes of database entries. Take a department store for example. The Store manager can see details for all of his employees, but each ...
0
votes
1answer
26 views

TYPO3 CSV download after SQL-Query

I created a button in my TYPO3 backend <f:link.action class="btn btn-default" action="redirectDownload" additionalAttributes="{role: 'button'}"> <core:icon identifier="actions-...
2
votes
2answers
69 views

How to disable FOREIGN KEY CONSTRAINT when using Doctrine generate migration?

I often change/add some field in Entity and using bin/console make:migration to generate migrations, that's convenience just like in Rails or Django. But I do not need Foreign Key Constraint when I am ...
0
votes
1answer
42 views

Symfony API Platform entity inheritance

My project uses doctrine2 Class Table Inheritance on entities and API Platform to provide API endpoint. /** * @ORM\Entity(repositoryClass="App\Repository\PartyRepository") * @ORM\InheritanceType("...
0
votes
1answer
24 views

Doctrine Invalid Mapping File Exception when trying to generate entities

I'm creating a entity for my bundle but if i want to generate my entity with php bin/console make:entity --regenerate App\\VacationManger\\Entity it shows following error: Invalid mapping file 'App....
-1
votes
0answers
15 views

generate:doctrine:entities on local instance with no Database

I have an issue where when I run the Symfony command "generate:doctrine:entities" on my local machine I get the error message: [Doctrine\DBAL\Exception\ConnectionException] ...
0
votes
0answers
13 views

Mysql select ordered by max results of join selection

I have a table categories which have ManyToMany association called attributes. I want to search category by related attributes. However it may not be exact match. For example, category1 has ...
1
vote
0answers
27 views

Datetime convert to string in object of class

I know there are a lot open topics for this question but I wasn't able to find any solution. I am trying to get my object of class from entity in symfony via getter and I have trouble getting ...
0
votes
0answers
23 views

How to use doctrine orm Multiple Entity Managers in one function

I am using Codeigniter 3 and I created two database i.e A and B. Now I want to make two queries into one function where query one will call entity manager A and query two will call Entity manager B. ...
0
votes
1answer
16 views

jms serializer groups not working in child entities

jms serializer groups not working in child entities class User extends BaseUser { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ ...
0
votes
1answer
25 views

Delete post without loading page - symfony4

I am new to Symfony. I want to delete my post using the jquery DELETE method. I have jquery code delete my post when I click on the delete button it reloads the page after confirmation but didn't ...
-2
votes
3answers
38 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 ...
0
votes
0answers
11 views

PHP script not finding Mongo records (Doctrine)

I have a script that takes Mongo records and transfers them to a MySQL table. This script functions just fine when it finds records. I'm using PHP and an old Doctrine installation to access Mongo, and ...
0
votes
1answer
24 views

Argument 1 passed to App\Entity\Rating::setPost() must be an instance of App\Entity\Post or null - Symfony4

I am new to Symfony4. I have a problem related to the set value in the table by click button. I want to store the user id and post id in the table by click on the like button, but it gives me an error....
0
votes
2answers
19 views

Symfony doctrine doctrine:mapping:convert filter is not working

I need to import database structure from existing database. I tried with doctrine:mapping:import "App\Entity" annotation --path=src/Entity doctrine:mapping:convert xml src/Entity --from-database --...
0
votes
1answer
22 views

Doctrine - getOriginalEntityData on OnFlush

I want to keep a previous version of data entity in DDB. I create en listener on "OnFlush" for get old data of entity and persit another one entity ("data history" entite), but i can't find old data (...
2
votes
1answer
25 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
34 views

undefined offset in doctrine iterate

my problem is with batch processing in doctrine and doesnt work based on its documentation and it increments index in each iteration for example in my code it gives me error that undefined index 0 : $...
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
26 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 ...
1
vote
1answer
54 views

Why does autowiring provides a different entity manager instance for event subscribers?

I have different services in a symfony4 project, which get the entity manager injected. I found out, that doctrine event subscribers and services used by them get a different entity manager instance ...
1
vote
1answer
46 views

Symfony Doctrine oneToMany inverse array key

(sorry for the confusing title it's hard for me to explain in one sentence well!) I basically have 3 entities that are connected to each other: SlideshowSlide, SlideshowContent and Language. The ...
0
votes
1answer
45 views

Using EntityType to get data that are not existing in other entity

I want to make a form with select dropdown that contains data from Users entity and are not used in Admin entity Controller ->add('User', EntityType::class, [ 'class'=>Users::class, ...
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 ...
2
votes
0answers
32 views

Why do i get “table already exists”?

I'm trying to migrate to my database but i get a: The table with name 'compteur_honore.ingredientsrecettes' already exists. I checked my Entities and i don't see any mistakes, there must be one ...
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
38 views

Insert large amount of recrods to database with relationships and without duplicates

I got some records(around 30k) from a 3rd party with a structure similar to this(all strings): first_name, last_name, city Also I have 2 tables in MySQL: users and cities(around 25k records). The ...
1
vote
1answer
19 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
13 views

How to manage with Symfony/Doctrine removed “onUpdate” statement?

I'm trying to work with impoverished functionality of Doctrine where "onUpdate" declaration disappeared from current version. Is there any workaround allowing to use "ON UPDATE CASCADE" in migrations? ...
0
votes
0answers
37 views

Symfony intersection entity with 3 entities

I have 3 entities, domain, slideshow and slideshow_container. Basically, in our old system and database I created an intersection entity (/table) called Slideshow_slideshow_containers. Basically, a ...
1
vote
0answers
21 views

How to how to generate setters in doctrine?

In symfony there is command to generates getter/setter methods php bin/console make:entity --regenerate App I use doctrine without symfony and want to generate setters for new attribures. Is it ...
0
votes
0answers
23 views

How to Work with multiple Entity Managers and Connections in php

I am using Codeigniter 3 for my application and I created two database connections i.e Company and History. Now I want to make 2 queries where query 1 call company entity manager and second query ...
1
vote
0answers
36 views

Why doctrine search with where column parameter don't work?

I want to make column name in query as a parameter. $this->createQueryBuilder('b') ->where(':column LIKE :term ') ->orderBy('b.id', 'ASC') ->...
0
votes
0answers
34 views

Could not call entityManager->flush() outside foreach loop when update entity objects

I have a bunch of user-objects need to add a role to admin but after a foreach loop, I call entitymanager->flush() but it threw an error out. I'm using symfony 2.7. Here is my code: try { ...
1
vote
2answers
46 views

WHERE … IN query with sub-query in Doctrine queryBuilder or equivalent

In my Symfony 4 project I have a User entity and a UserRepository. I'm trying to implement the equivalent of this SQL query in the QueryBuilder(Doctrine 2) or even in DQL. SELECT * FROM user WHERE ...