doctrine-orm

Many to many relation with ON DELETE CASCADE with Symfony and Doctrine

吃可爱长大的小学妹 提交于 2020-12-31 10:48:59
问题 I want a simple many to many relation with Symfony and Doctrine. This is really a unidirectional one-to-many association can be mapped through a join table as the docs indicate I am using a YAML file for configure this with the following code: In file Content.orm.yml: manyToMany: comments: cascade: ["persist","remove"] onDelete: CASCADE options: cascade: remove: true persist: true #refresh: true #merge: true #detach: true orphanRemoval: false orderBy: null targetEntity: Comment joinTable:

Many to many relation with ON DELETE CASCADE with Symfony and Doctrine

℡╲_俬逩灬. 提交于 2020-12-31 10:48:49
问题 I want a simple many to many relation with Symfony and Doctrine. This is really a unidirectional one-to-many association can be mapped through a join table as the docs indicate I am using a YAML file for configure this with the following code: In file Content.orm.yml: manyToMany: comments: cascade: ["persist","remove"] onDelete: CASCADE options: cascade: remove: true persist: true #refresh: true #merge: true #detach: true orphanRemoval: false orderBy: null targetEntity: Comment joinTable:

Many to many relation with ON DELETE CASCADE with Symfony and Doctrine

点点圈 提交于 2020-12-31 10:48:33
问题 I want a simple many to many relation with Symfony and Doctrine. This is really a unidirectional one-to-many association can be mapped through a join table as the docs indicate I am using a YAML file for configure this with the following code: In file Content.orm.yml: manyToMany: comments: cascade: ["persist","remove"] onDelete: CASCADE options: cascade: remove: true persist: true #refresh: true #merge: true #detach: true orphanRemoval: false orderBy: null targetEntity: Comment joinTable:

Symfony Form with Doctrine Class Table Inheritance (CTI)

最后都变了- 提交于 2020-12-15 05:32:20
问题 In a previous question I ask how to handle large forms, outcome was Single Table Inheritance (STI) or CTI, Inheritance mapping. I've has chosen for CTI. Now i'm dealing how to create the form with CTI. A quick overview what kind or relation there are. Each inspection could have one or more surfaces . Each surface consists of many sub entities, like: surface_leakage , surface_tension or surface_slope . As you could see surface has the CTI with sub entities. Some fields overlap (put them in

How persist new Entity in Doctrine 2 prePersist method?

穿精又带淫゛_ 提交于 2020-12-12 11:34:45
问题 I've a Entity with @HasLifecycleCallbacks for define prePersist and preUpdate method. My PrePersist method is /** * @ORM\OneToMany(targetEntity="Field", mappedBy="service", cascade={"persist"}, orphanRemoval=true) */ protected $fields; /** * @PrePersist() */ public function populate() { $fieldsCollection = new \Doctrine\Common\Collections\ArrayCollection(); $fields = array(); preg_match_all('/%[a-z]+%/', $this->getPattern(), $fields); if (isset($fields[0])) { foreach ($fields[0] as $field

Symfony 4 multiple entities in single form

泪湿孤枕 提交于 2020-12-08 12:44:40
问题 Been trying for hours and hours to get my multi entity form to work, but it really breaks my head and none of the examples I've found work. I checked the Collection form type documentation and form collections, as well as the Entity form type. I have a User entity, UserRole entity and a Role entity. UserRole contains a userID and a roleID. Just a linking table. The form shows fields to create a User and I want to be able to as well select a new Role for the new user. So I've tried to use the

Symfony 4 multiple entities in single form

余生长醉 提交于 2020-12-08 12:38:51
问题 Been trying for hours and hours to get my multi entity form to work, but it really breaks my head and none of the examples I've found work. I checked the Collection form type documentation and form collections, as well as the Entity form type. I have a User entity, UserRole entity and a Role entity. UserRole contains a userID and a roleID. Just a linking table. The form shows fields to create a User and I want to be able to as well select a new Role for the new user. So I've tried to use the

Symfony 4 multiple entities in single form

好久不见. 提交于 2020-12-08 12:38:41
问题 Been trying for hours and hours to get my multi entity form to work, but it really breaks my head and none of the examples I've found work. I checked the Collection form type documentation and form collections, as well as the Entity form type. I have a User entity, UserRole entity and a Role entity. UserRole contains a userID and a roleID. Just a linking table. The form shows fields to create a User and I want to be able to as well select a new Role for the new user. So I've tried to use the

Doctrine messing up queries on Entities with an Extends

假如想象 提交于 2020-12-06 04:15:40
问题 My task is (or was) simple: There is a variety but finite types of "Post", each with a vastly different set of properties while all sharing a couple core properties (like: Title, Content, Published, etc) What I set out to do, was create a base Post entity with all the shared properties (as mentioned above), and have this entity as sort of a "Governor" entity, but more on that in a second. All the different Category entities would extend off of this base Post entity. I did it this way mostly

Doctrine messing up queries on Entities with an Extends

那年仲夏 提交于 2020-12-06 04:15:05
问题 My task is (or was) simple: There is a variety but finite types of "Post", each with a vastly different set of properties while all sharing a couple core properties (like: Title, Content, Published, etc) What I set out to do, was create a base Post entity with all the shared properties (as mentioned above), and have this entity as sort of a "Governor" entity, but more on that in a second. All the different Category entities would extend off of this base Post entity. I did it this way mostly