doctrine

Using the same EntityListener for multiple entities with differrent service argument

做~自己de王妃 提交于 2021-02-10 07:25:51
问题 As an EntityListener is registered as a service, is it possible to register the same class multiple times with different argument and associate each of them with a particular entity ? Considering the following entities : /** * Class EntityA * @ORM\Entity * @ORM\EntityListeners({"myBundle\EventListener\SharedListener"}) */ class EntityA implements sharedBehaviourInterface { // stuff here } /** * Class EntityB * @ORM\Entity * @ORM\EntityListeners({"myBundle\EventListener\SharedListener"}) */

Symfony: Base table or view already exists: 1050 Table 'migration_versions' already exists

寵の児 提交于 2021-02-10 05:15:31
问题 I've done something horribly wrong to my migration_versions, deleted the versions from the migrations folder now and I get this error when try to run anything to do with migrations. Could someone point me in the direction of where to start to fix this? If I drop the database and then make:migration , the migration_versions table appears in the db. After that if I try to run php bin/console doctrine:migrations:migrate I get the error: In AbstractMySQLDriver.php line 38: An exception occurred

Symfony: Base table or view already exists: 1050 Table 'migration_versions' already exists

人盡茶涼 提交于 2021-02-10 05:15:27
问题 I've done something horribly wrong to my migration_versions, deleted the versions from the migrations folder now and I get this error when try to run anything to do with migrations. Could someone point me in the direction of where to start to fix this? If I drop the database and then make:migration , the migration_versions table appears in the db. After that if I try to run php bin/console doctrine:migrations:migrate I get the error: In AbstractMySQLDriver.php line 38: An exception occurred

Request on key/value in a JSON type field with Doctrine2

耗尽温柔 提交于 2021-02-08 13:18:18
问题 I'm trying to figure out how, in a symfony 3.4 app, to retrieve (through a repository method, with a DQL request for example) entities depending on a value for a specific key in a "json" typed column. Saw there's some stuff possible with postgre but I didnt find anything with mariaDB Let's say I get an entity Letter with this property : /** * * @ORM\Column(type="json") */ private $metadatas; which contains, for example: { "key1": "value", "key2": "value" } How can I, or, Is it possible to

Add a new column in Doctrine 2 in Zend Framework

拈花ヽ惹草 提交于 2021-02-08 09:28:20
问题 I have Zend framework script with doctrine 2. I need to add a new column, what is the correct chronology to go about doing that i.e create column, update entities, run migration etc. Any help appreciated. 回答1: If you want manually then create a column in database table and specify that column in you entity class as bellow /** * @ORM\Column(type="string") // if column is varchar */ protected $title; if you have already set a CLI for generate entity and database schema file Then use this -- add

How to override bundled Doctrine repository in Symfony

大城市里の小女人 提交于 2021-02-07 14:35:13
问题 I have an independent Symfony bundle (installed with Composer) with entities and repositories to share between my applications that connect same database. Entities are attached to every applications using configuration (yml shown): doctrine: orm: mappings: acme: type: annotation dir: %kernel.root_dir%/../vendor/acme/entities/src/Entities prefix: Acme\Entities alias: Acme Well, it was the easiest way to include external entities in application, but looks a bit ugly. Whenever I get repository

How to override bundled Doctrine repository in Symfony

≯℡__Kan透↙ 提交于 2021-02-07 14:34:49
问题 I have an independent Symfony bundle (installed with Composer) with entities and repositories to share between my applications that connect same database. Entities are attached to every applications using configuration (yml shown): doctrine: orm: mappings: acme: type: annotation dir: %kernel.root_dir%/../vendor/acme/entities/src/Entities prefix: Acme\Entities alias: Acme Well, it was the easiest way to include external entities in application, but looks a bit ugly. Whenever I get repository

How to override bundled Doctrine repository in Symfony

北城以北 提交于 2021-02-07 14:34:30
问题 I have an independent Symfony bundle (installed with Composer) with entities and repositories to share between my applications that connect same database. Entities are attached to every applications using configuration (yml shown): doctrine: orm: mappings: acme: type: annotation dir: %kernel.root_dir%/../vendor/acme/entities/src/Entities prefix: Acme\Entities alias: Acme Well, it was the easiest way to include external entities in application, but looks a bit ugly. Whenever I get repository

How to override bundled Doctrine repository in Symfony

被刻印的时光 ゝ 提交于 2021-02-07 14:34:20
问题 I have an independent Symfony bundle (installed with Composer) with entities and repositories to share between my applications that connect same database. Entities are attached to every applications using configuration (yml shown): doctrine: orm: mappings: acme: type: annotation dir: %kernel.root_dir%/../vendor/acme/entities/src/Entities prefix: Acme\Entities alias: Acme Well, it was the easiest way to include external entities in application, but looks a bit ugly. Whenever I get repository

PHP Fatal error: Uncaught Error: Class not found

巧了我就是萌 提交于 2021-02-05 12:13:35
问题 I am trying to go trough tutorial of doctrine here is official website. And I got an error in Starting with the Product Entity part. This is what I write to terminal: $ php create_product.php ORM PHP Fatal error: Uncaught Error: Class 'product' not found in /home/vaclav/Server/vssk/VSSK/project/create_product.php:8 Stack trace: #0 {main} thrown in /home/vaclav/Server/vssk/VSSK/project/create_product.php on line 8 回答1: Solved with adding: require_once 'patch_to_your_class/Product.php'; to