Skip to main content

All Questions

Filter by
Sorted by
Tagged with
1 vote
1 answer
705 views

Symfony: Persisting in a "ManyToMany with extra data" after implementing bridge entity

I am trying to persist a "collection" of objects that are related between them through an entity that is in a ManyToOne relation with two other entities in order to provide a kind of "...
Juan Etxenike's user avatar
0 votes
1 answer
322 views

When deleting an entity with associate all related data is deleted but want to keep associate data in symfony

I have two entities which are below :- Website Posts In the website entity, I have given OneToMany relation, And in the posts entity, I have given the ManytoOne relation. Website Entity:- /** * @...
Hims V's user avatar
  • 125
0 votes
2 answers
2k views

Doctrine ORM self ManyToOne fails to insert because of duplicate entries

Problem Is there a way that Doctrine recognizes the existing objects when persist with cascade={"persist"} on a ManyToOne relation instead and do not fail when trying to insert it again and ...
Arthur Eudeline's user avatar
1 vote
1 answer
586 views

Doctrine & ManyToOne Foreign key issue

I'm trying to create a relation between a Language entity and a User entity, one language has many users, but a user has one language. So I created this relation as follow : In User.php: /** * @ORM\...
A.Rey's user avatar
  • 75
3 votes
1 answer
5k views

Symfony 4/Doctrine 2 - fetching real object not the proxy

I have a following entity: /** * @ORM\Entity(repositoryClass="App\Repository\CourseLevelRepository") */ class CourseLevel { /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(...
zleek's user avatar
  • 217
0 votes
1 answer
493 views

How to reference many-to-one association in Doctrine 2 by a non-primary key

As I understand, Doctrine requires many-to-one associations to reference the primary key on the one side. (See here or here) How would one solve a many-to-one association referenced by an unique key ...
arueckauer's user avatar
0 votes
1 answer
303 views

Doctrine persisting Many-To-One entities

I'm using Zend Framework 3 with Doctrine and I'm trying to save an Entity "Cidade" related to another Entity "Estado" witch is already stored in the database. However, Doctrine is trying to persist ...
Siipe's user avatar
  • 478
1 vote
0 answers
89 views

Remove all related children in Symfony entity ManyToOne

That is my relations: in CategoryField Entity: manyToOne: category: targetEntity: Category inversedBy: fields joinColumn: name: category_id ...
alias's user avatar
  • 155
0 votes
1 answer
57 views

Doctrine, ralation ManyToOne

When a try update my database I got error: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (symfony.#sql-d8c_55, CONSTRAINT ...
pierzcha's user avatar
0 votes
2 answers
73 views

doctrine2, retrieve associated data from inverse side

I have 2 entities. The simple logic is that a user has many delivery address, so in the future they will be able to choose one of them for their deliveries. First entity, Direccion (address). <?php ...
Sebastian Quevedo's user avatar
0 votes
0 answers
80 views

doctrine ManyToOne relation crashes symfony 3.3.1

We have an old postgres 9.2 database with more than 400 tables. I used the symfony console to generate the entities, I created the repository classes that I need myself. When I remove all relations ...
Vencarii's user avatar
0 votes
1 answer
2k views

How to remove a collection element without EntityManager#remove(...) in Doctrine 2?

I have a classical construction like EntityA OneToMany EntityB. Implemented as a bidirectional relationship: the EntityB has a property $entityA of type EntityA and the EntityA has a property $...
automatix's user avatar
  • 14.4k
0 votes
1 answer
2k views

How to persist only one end of a relationship and the other one only if the entity doesn't exist?

I have a complex/nested object created by automatic hydration from Zend\Form data. Now I want to save it with Doctrine 2. The best case would be just one persist(...) and one flush(...) call on the ...
automatix's user avatar
  • 14.4k
0 votes
0 answers
112 views

How to deactivate the cascading saving in Doctrine 2?

I have Entities Foo and Bar with a bidirectional ManyToOne relationship: /** * Foo * * @ORM\Table( * name="foo", * indexes={ * ... * } * ) * @ORM\Entity * @ORM\...
automatix's user avatar
  • 14.4k
4 votes
2 answers
8k views

Symfony Doctrine Hydrator - With custom hydrator I lose my ManyToOne relation

I would like to extends ObjectHydrator to benefit of the hydration of my ManyToOne relation and add extra field to the Entity. Here is my hydrator: StatisticsDataHydrator.php namespace AppBundle\...
Vincent Guyard's user avatar
0 votes
2 answers
323 views

In Doctrine2, cannot remove unidirectional many-to-one relation (cannot set to null)

I have an Authentication entity that works like a user entity, and a Country entity which has a property related to Authentication entity unidirectionally: /** * @var Authentication * * @ORM\...
Kibele's user avatar
  • 105
0 votes
1 answer
32 views

How to remove owing side from inversed MTO relation side without cascade option?, how to update the inversed side of relation?

How to remove owing side from inversed MTO relation side without cascade option? , how to update the inversed side of relation without cascade option? Error is that if i change address(OTM) of the ...
olga's user avatar
  • 969
0 votes
1 answer
2k views

ManyToOne on queryBuilder symfony 3

I have 2 entities Federation and Pays , the entity Federation has a property ManyToOne: /** * @ORM\ManyToOne(targetEntity="Stage\AdminBundle\Entity\Pays") */ public $nomPays; I ...
Maryem Samet's user avatar
1 vote
1 answer
1k views

Symfony schema:update error

I have an error which i can't fix cause i can't find the problem. The error in the console says: [Symfony\Component\Debug\Exception\FatalThrowableError] Parse error: syntax error, unexpected 'public' ...
Daren Smit's user avatar
0 votes
2 answers
885 views

Doctrine select many from the one (many-to-one unidirectional (different bundles))

Working on a legacy project which restricts the options available, has left me in a situation where I need to solve the following problem, ideally with doctrine. I have two entities in different ...
ViniH's user avatar
  • 756
1 vote
1 answer
71 views

Symfony 3 and Doctrine relationship

I am having two entities A and B. Let's say entity A has a primary key 'foo' and the entity B has a variable named 'bar'. I am trying to establish the "Many to one" association between these two. And ...
Kavya Rao's user avatar
0 votes
1 answer
719 views

Symfony create new object many to one error call undefined method

I have set up a many to one relation and want to add a new product-object linked to its category. Related to this I have 2 questions: I get stuck on saving the category object to the new product. ...
zef's user avatar
  • 649
1 vote
1 answer
121 views

How to reference child elements in a Many-to-One relationship in ZF2 and Doctrine

If I develop a project using ZF2 and Doctrine that hydrates an object with a Many-to-Many relationship similar this Doctrine hydrator tutorial, the parent fieldset would look like this: namespace ...
jcropp's user avatar
  • 1,246
1 vote
2 answers
1k views

Doctrine clear() and many to one relation

I need to import large data from csv file (about 1m records). For avoid memory leaks I tried bulk insert from doctrine documentation: $batchSize = 20; for ($i = 1; $i <= 10000; ++$i) { //code ...
gawellus's user avatar
2 votes
1 answer
4k views

Doctrine targetEntity abstract class

I get unnecessary queries then entity has ManyToOne relationship with abstract class. My classes structure: /** * @ORM\Entity * @ORM\Table(name="tb_payment_info") * @ORM\InheritanceType("JOINED") ...
sNICkerssss's user avatar
  • 6,420
1 vote
1 answer
372 views

Symfony form many-to-many -> many-to-one

I have three different entities - Newsletter - NewsletterOptions - Options I need the NewsletterOptions entity, because I need extra properties in that entity, so a manyToMany relation is no option. ...
Paul's user avatar
  • 329
0 votes
2 answers
85 views

Doctrine2 Save Many To One Objects

The relation is: MailTemplate may be used by many EMail but EMail is associated only to one MailTemplate. The problem occurs when trying to insert new records. The error is: Cannot access empty ...
Daniel Gasser's user avatar
0 votes
1 answer
573 views

Doctrine 2 @ManyToOne attribute always return null

I have these entities /** @ORM\Entity */ class Produto { /* Other attributes */ /** * @ORM\ManyToOne(targetEntity="Produto\Entity\Categoria") * @ORM\JoinColumn(name="categoria_id"...
renan moraes's user avatar
1 vote
0 answers
417 views

Doctrine many to one relationship versioning

I have an application that I'm developing in symfony 2 with doctrine. The problem I'm facing is the slowly changing dimension. For example I have three Entities: Dossier, Payout and PayoutCategory. ...
lorenzobe's user avatar
0 votes
0 answers
418 views

Many to One Unidirectional relation in symfony2 has "No Association error"

I am trying to create a many to one unidirectional relationship between two tables. dateTime and availibilityList are two entities, one list may have multiple date and time. I added the annotations ...
Geetika's user avatar
  • 820
0 votes
1 answer
681 views

Doctrine Orm - multiple OneToMany joins to the same table

I am struggling with the following. I am writing a basic User / Order relationship where a number of users play different roles. Each order is therefore linked to a user who is the initiator of the ...
HappyCoder's user avatar
  • 6,125
0 votes
1 answer
2k views

Many to One Relation in Symfony 2

I have a problem related to Doctrine2: 1- I have two tables joining on a many-to-one relation: Table 1 - Activity The Schema: Backend\adminBundle\Entity\Activity: type: entity table: activity ...
Lola's user avatar
  • 3
0 votes
1 answer
660 views

How to set up a zf2 form for a ManyToOne doctrine mapping

I'm having trouble hydrating a form in zf2 using a doctrine ManyToOne unidirectional relationship. My entities look like this: namespace AdminMyPages\Entity; class MyPageItem { // ... /** ...
jcropp's user avatar
  • 1,246
0 votes
1 answer
628 views

How to configure entities in zf2 for ManyToOne unidirectional doctrine mapping

I'm having trouble developing a form in zf2 using a doctrine ManyToOne unidirectional relationship. My entities look like this: namespace AdminMyPages\Entity; class MyPageItem { // ... /**...
jcropp's user avatar
  • 1,246
0 votes
1 answer
647 views

Symfony2 Many to one - one to many without join table

I have "Project" entity which can have several Benefits, while a benefit belongs to just one Project: To me it seems a many to one - one to many relationship. I followed the indication here The ...
Sergio Negri's user avatar
  • 2,063
0 votes
1 answer
108 views

Children count depends on method in test

While experimenting with a self-referencing ManyToOne entity I find the count of children depends on the method used to find the parent. If the Repository is used, the test fails with Failed ...
geoB's user avatar
  • 4,704
0 votes
1 answer
818 views

can we use traits to map manyToOne relationship with doctrine2?

I am frequently associating a vote entity in other ones with symfony2 / doctrine 2. This is done through a manyToOne relationship. I was considering using a trait to include the association and its ...
Sébastien's user avatar
  • 5,443
0 votes
2 answers
2k views

Doctrine2: Many-to-One delete relations on update

I have a software which can own many screenshots. This is the software class: class Software { public function __construct() { $this->screenshots = new ArrayCollection(); } /**...
Anton's user avatar
  • 1
0 votes
1 answer
3k views

Symfony/Doctrine 2 ManyToOne relationship, ORM does not retain set value for column, error ensues

I'm creating a ManyToOne relationship in table B, to one entry in table A. I am using a particular key_id parameter, which is set in the controller, before being flushed to the db. My problem is ...
Victor S's user avatar
  • 5,122
9 votes
2 answers
2k views

Symfony2 / Doctrine2 - ManyToOne - Save inverse side

I am new to Symfony and Doctrine. I have an entity "User" and an entity "Type". One user can have one favorite type and one type can have many users that have that specific type as favorite. So I ...
Simon Hessner's user avatar
0 votes
1 answer
239 views

Symfony2 / Doctrine : OneToMany/ManyToOne between 2 bundles

I have 2 bundles : a core one (C) and an optional one (O). I create an entity in O with a OneToMany property referring an entity in C. I want to inject the related ManyToOne in the entity in C (I ...
Pierre Gilmour's user avatar
7 votes
1 answer
3k views

Two attributes sharing the same OneToMany relationship to one entity Symfony2

Let's first describe my situation. I am using Symfony2 and I have a problem with a relationship between my entities. I have two entities that are linked together. The two entities are ...
Etienne Noël's user avatar
4 votes
1 answer
197 views

Adding Entity with Many-To-One association and inverse side already existing in the database

Using Doctrine 2 with Zend Framework 2. Been thinking of how I am meant to persist an entity with a field having a Many-To-One association with another entity that already exists in the database. ...
burntblark's user avatar
  • 1,690
0 votes
1 answer
197 views

Doctrine2 Associations mapping and doctrine annotations

I've broken my head trying to set annotations for my 2 entities in order to use join tables. I have 2 tables: user and cart. Cart contains user ids with products which users selected. 1 user can have ...
yuriscom's user avatar
  • 650
3 votes
0 answers
1k views

Doctrine OneToMany cascade persist on foreign key

i've trouble with a OneToMany relation. I'm currently working on a log analyser, that stores the original log rows as well as the parsed message from the row including the keywords. The Database ...
torsten's user avatar
  • 453
2 votes
1 answer
503 views

build form for tables with many relations

I have got a problem to build a forms with many relations between tables. The structure of relations you can see on below picture: My relations in YML: ######### Products.orm.yml ######### type: ...
Marek's user avatar
  • 440
3 votes
1 answer
2k views

How to handle a file upload with a many to one relationship in Symfony2?

I'm creating a ticket system for practice purposes. Right now I'm having a problem with uploading files. The idea is that a ticket can have multiple attachments, so I created a many-to-one ...
Njerpie's user avatar
  • 51
11 votes
1 answer
14k views

Doctrine OneToMany relationship error

I am trying to set up some ManyToOne/OneToMany relationships on objects in my database using Doctrine (2.2.3+) via Symfony2 (2.3.0) and am getting a strange error. Here are the relevant parts of the ...
Aaron Luman's user avatar
2 votes
1 answer
4k views

Doctrine2: Many-To-Many with extra columns in reference table (add record)

Spoiler: I think I found the answer but I'm not 100% sure ;) I've been looking at this question for a while but I cannot manage to make it work. So I've create dummies Entities to test the relation ...
maxwell2022's user avatar
  • 2,857
0 votes
1 answer
4k views

Symfony 2 - ManyToOne Bidirectional relationship behaviour

I had a big time trying to figure out how to setup a ManyToOne -> OneToMany relationship with Doctrine 2 and it still not working... Here is the application behaviour: A site has Pages A User can ...
maxwell2022's user avatar
  • 2,857