doctrine-orm

How to define a Doctrine mappedSuperclass using XML or YAML instead of annotation mapping

久未见 提交于 2020-03-05 03:26:57
问题 The following script comes from https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/inheritance-mapping.html#mapped-superclasses, and was only changed to include a second sub-class. It is my understanding that MappedSuperclassBase cannot exist by itself but must be extended by one and only one sub-class (i.e. either EntitySubClassOne or EntitySubClassTwo ), and is the same concept as supertype/subtype for SQL. Agree? How is a super/sub type defined using either YAML or XML

Gearman, ZF2, Doctrine2, MySQL, SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

大城市里の小女人 提交于 2020-02-28 06:59:53
问题 I use ZF2, Doctrine2, MySQL, Gearman. When working Gearman periodically has an error: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away. I tried these steps to fix the problem: 1) I investigated MySQL queries. Queries haven't any problem. It's simple (without subqueries) and fast. For example, this is EXPLAIN of one of queries when MySQL server has gone away. +-------------+-------+-------+-----------------------+-----------------------+---------+-------+------+ | select_type |

Doctrine 2 Command line print Cygwin configuration

笑着哭i 提交于 2020-02-27 08:27:27
问题 I am trying to use Doctrine 2 in my project, but when I try to access the command line to import the Entities from my database to generate the files, it print the code from vendor/bin/doctrine dir=$(d=${0%[/\\]*}; cd "$d"; cd '../doctrine/orm/bin' && pwd) # See if we are running in Cygwin by checking for cygpath program if command -v 'cygpath' >/dev/null 2>&1; then # Cygwin paths start with /cygdrive/ which will break windows PHP, # so we need to translate the dir path to windows format.

How to get different DBAL Connection in Symfony2 Doctrine2

血红的双手。 提交于 2020-02-24 14:48:03
问题 I have two connection in my config.yml file doctrine: dbal: default: connection2 Then in my class , i use this $em = $this->container->get('doctrine')->getEntityManager(); But it is getting the default connection. How can i use the second Connection Is it possible that i can use it from service. 回答1: You have to define both a DBAL connection and an entity manager in the config.yml doctrine: dbal: default_connection: connection1 connections: connection1: ... connection2: ... orm: default

Doctrine/Symfony entity generator and generating entity from one table

纵饮孤独 提交于 2020-02-24 12:08:31
问题 I have already a few entities, but now a new table appeared in a database, and I'd like to generate an entity on only this one table. I already saw this, but I have further questions. I already have a User entity (and a db table). Now, the new table is called "Report" (no entity for it right now, I want to create it) and it has a foreign key to User. There are also a few more foreign keys. If I do what is suggested in the above answer, that is: $ php app/console doctrine:mapping:import -

Doctrine/Symfony entity generator and generating entity from one table

江枫思渺然 提交于 2020-02-24 12:07:47
问题 I have already a few entities, but now a new table appeared in a database, and I'd like to generate an entity on only this one table. I already saw this, but I have further questions. I already have a User entity (and a db table). Now, the new table is called "Report" (no entity for it right now, I want to create it) and it has a foreign key to User. There are also a few more foreign keys. If I do what is suggested in the above answer, that is: $ php app/console doctrine:mapping:import -

Doctrine2 bulk import try to work with another entity

倾然丶 夕夏残阳落幕 提交于 2020-02-24 11:19:07
问题 I'm working on a members import batch (with insertions and updates) for a big project with a lot of entities such as Member , Client , Group , ... . After reading the chapter related to bulk imports in Doctrine doc, I've implemented this code : $batchSize = 20; $i = 0; foreach ($entities as $entity) { $this->getEntityManager()->persist($entity); if (($i % $batchSize) === 0) { $this->getEntityManager()->flush(); $this->getEntityManager()->clear(); } } $this->getEntityManager()->flush(); $this-

How to get Doctrine2 entity identifier without knowing its name

混江龙づ霸主 提交于 2020-02-15 07:11:31
问题 I am attempting to create an abstracted getId method on my base Entity class in Symfony2 using Doctrine2 for a database where primary keys are named inconsistently across tables. When inspecting entity objects I see there is a private '_identifier' property that contains the information I am trying to retrieve but I am not sure how to properly access it. I'm assuming there is some simple Doctrine magic similar to: public function getId() { return $this->getIdentifier(); } But I haven't

How to get Doctrine2 entity identifier without knowing its name

余生颓废 提交于 2020-02-15 07:10:09
问题 I am attempting to create an abstracted getId method on my base Entity class in Symfony2 using Doctrine2 for a database where primary keys are named inconsistently across tables. When inspecting entity objects I see there is a private '_identifier' property that contains the information I am trying to retrieve but I am not sure how to properly access it. I'm assuming there is some simple Doctrine magic similar to: public function getId() { return $this->getIdentifier(); } But I haven't

It seems I have two Doctrine Entity Managers but I want only one! o.O

白昼怎懂夜的黑 提交于 2020-02-08 07:54:59
问题 I've spent last days solving a very subtle bug in my bundle. Practically I get a Job entity from the database. This entity has a one-to-one , self-referencing relation to another Job entity on the property retryOf . When I try to update the retrieved Job#status property, I get the following exception thrown: [Doctrine\ORM\ORMInvalidArgumentException] A new entity was found through the relationship 'SerendipityHQ\Bundle\CommandsQueuesBundle\Entity\Job#retryOf' that was not configured to