doctrine

Doctrine OneToOne identity through foreign entity exception on flush

二次信任 提交于 2020-02-02 03:09:20
问题 I have User and UserProfile OneToOne–related Doctrine ORM entities. They should always exist as a pair, there should be no User without UserProfile . User should get its id from autoincrement, while UserProfile should have User's id. So they both should have the same id and there is no other column to set up the relationship (Doctrine docs: Identity through foreign Entities). UserProfile's id is both a primary key (PK) and foreign key (FK) at the same time. I managed to set it up, but it

Doctrine fixtures - circular references

别来无恙 提交于 2020-02-01 04:15:51
问题 Is there any way to load fixtures that have circular referencing? As an example I have the following fixture: BusinessEntityTeam: Nicole_Team: name: Nicole's Team Manager: [Nicole] Business: [ACMEWidgets] sfGuardUser Nicole: first_name: Nicole last_name: Jones email_address: nicole@example.com username: nicole password: nicole Groups: [Group_abc] Team: [Nicole_Team] As you can see, Nicole_Team references Nicole... but Nicole also references Nicole_Team. When Manager wasn't a required column

Are Doctrine relations affecting application performance?

半腔热情 提交于 2020-01-30 04:04:53
问题 I am working on a Symfony project with a new team, and they decide to stop using Doctrine relations the most they can because of performances issues. For instance I have to stock the id of my "relation" instead of using a ManyToOne relation. But I am wondering if it is a real problem? The thing is, it changes the way of coding to retrieve information and so on. 回答1: The performance issue most likely comes from the fact that queries are not optimised. If you let Doctrine (Symfony component

Doctrine 2 OneToMany Cascade SET NULL

半腔热情 提交于 2020-01-26 23:57:43
问题 The error Cannot delete or update a parent row: a foreign key constraint fails. The classes class Teacher { /** *@ORM\OneToMany(targetEntity="publication", mappedBy="teacher") */ protected $publications; } class Publication { /** * @ORM\ManyToOne(targetEntity="Teacher", inversedBy="publications") * @ORM\JoinColumn(name="teacher_id", referencedColumnName="id") */ protected $teacher; } I want What I want is to make it that when you delete a teacher, the id_teacher is modified to NULL. I want to

Doctrine 2 OneToMany Cascade SET NULL

江枫思渺然 提交于 2020-01-26 23:57:12
问题 The error Cannot delete or update a parent row: a foreign key constraint fails. The classes class Teacher { /** *@ORM\OneToMany(targetEntity="publication", mappedBy="teacher") */ protected $publications; } class Publication { /** * @ORM\ManyToOne(targetEntity="Teacher", inversedBy="publications") * @ORM\JoinColumn(name="teacher_id", referencedColumnName="id") */ protected $teacher; } I want What I want is to make it that when you delete a teacher, the id_teacher is modified to NULL. I want to

Splitting a ManyToMany association into 2 pairs of OneToMany/ManyToOne (Doctrine)

耗尽温柔 提交于 2020-01-25 12:27:25
问题 I'll expose the case with the example (it'll be clearer): I have 'Groupies' (since group is a reserved name) and I have Companies. A Groupie may choose several Companies, and the same aplies in reverse (typical ManyToMany asociation). The thing is: I need to persist some additional data wich are specific of the association itself (let's call it 'Choice'). So, the ManyToMany is replaced by two pairs of OneToMany/ManyToOne asociations, and now each 'choice' has only one 'groupie' and one

Symfony Doctrine Many to Many insert

风流意气都作罢 提交于 2020-01-25 03:44:08
问题 I have a problem with my entities and controllers in Symfony. I would insert on my DB value in a many to many table generated. Entity Requests with only many to many elements class Requests { /** * @ORM\ManyToMany(targetEntity="Tipi", inversedBy="requests") * @ORM\JoinTable(name="tipi_richieste") */ private $tipi; public function __construct() { $this->tipi = new \Doctrine\Common\Collections\ArrayCollection(); } /** * Add tipi * * @param \AppBundle\Entity\Tipi $tipi * * @return Requests */

Symfony: Doctrine - checking there's a connection

此生再无相见时 提交于 2020-01-24 23:34:27
问题 Is there a simple way to debug why Doctrine is not connecting to MySQL? config.yml has: # Doctrine Configuration doctrine: dbal: driver: pdo_mysql host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_user%" password: "%database_password%" and parameters.yml seems to have the correct connection information in it. E.g. parameters: database_host: 127.0.0.1 database_port: null database_name: <my database name> database_user: <my database user> database

Symfony: Doctrine - checking there's a connection

情到浓时终转凉″ 提交于 2020-01-24 23:34:13
问题 Is there a simple way to debug why Doctrine is not connecting to MySQL? config.yml has: # Doctrine Configuration doctrine: dbal: driver: pdo_mysql host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_user%" password: "%database_password%" and parameters.yml seems to have the correct connection information in it. E.g. parameters: database_host: 127.0.0.1 database_port: null database_name: <my database name> database_user: <my database user> database

Doctrine ODM returns proxy object for base class instead of sub-classed document

余生颓废 提交于 2020-01-24 21:50:09
问题 During my work on providing new functionality to my project, I decided to expand models. I decided to use base class, grouping common methods, with few sub-classes, all kept in a single collection. Base, abstract class: /** * @MongoDB\Document(repositoryClass="EntryRepository") * @MongoDB\MappedSuperclass * @MongoDB\InheritanceType("SINGLE_COLLECTION") * @MongoDB\DiscriminatorField(fieldName="type") * @MongoDB\DiscriminatorMap({"entry"="Application_Model_Entry", "image"="Application_Model