doctrine

Doctrine merge: DateTime field always updated

北战南征 提交于 2019-12-30 05:57:09
问题 I create a new Entity with an existing Id , and I want to update the related database record. Doctrine merge has been my best friend: recognizes if there are changes and generates the correct update query. $entity = new Entity(); $entity->setId(1); $entity->setName('test'); $EntityManager->merge($entity); $EntityManager->flush(); Suppose that the element with the id=1 already exists in the db: if the name is different from 'test', Doctrine generates this query: UPDATE table SET name = ? WHERE

getReference() of doctrine Entity Manager

我的梦境 提交于 2019-12-30 02:10:15
问题 Situation: I want to use the getReference() function of doctrine2 Entity Manager. However, in a situation where I ask for an object that has been deleted from the database, I obtain a proxy if I ask for that same object more than once. An example: //A random article object...that has been deleted from the database $articleClass = 'Acme\ArticleBundle\Entity\Article'; $articleIdentifiers = array('id'=>1); $i = 0; //We ask for its reference twice do{ try { echo "a"; $subject = $this->em-

Doctrine 2 - Log changes in manyToMany relation

女生的网名这么多〃 提交于 2019-12-29 18:49:12
问题 I use Loggable behavioral extension to log changes in my entities. I want to log changes in manyToMany relations too. I want to show to user this kind of change log: +--------------------------------------------------+ | Article "My Article" change log: | +-------+------------+-----------------------------+ | Who | When | What | +-------+------------+-----------------------------+ | Admin | 2015-07-01 | Removed tags "tag1", "tag2" | | Admin | 2015-07-01 | Added tags "tag3" | +-------+--------

Symfony2 YAML Entity field not being bound

喜夏-厌秋 提交于 2019-12-29 08:25:18
问题 I have a project on Symfony2. I should say that I don't consider myself a master of Symfony2 in any way. You could say I'm a newbie. My entities are bound via YAML to database and an Entity class is created in php not bound by annotations. I have an Entity likes this: Project/CoreBundle/Resources/config/doctrine/Card.orm.yml Project/CoreBundle/Entity/Card.php Card - is a dashboard element, that can be dragged around for user's convenience. The corresponding Card.orm.yml and Card.php have

Extra changeColumns in Doctrine generate-migrations-diff

旧街凉风 提交于 2019-12-29 08:01:28
问题 I'm generating migrations between different yaml schema files: i.e. running: symfony doctrine:generate-migrations-diff And the resulting migration file has a whole slew of changeColumn calls that weren't added in the last schema file change. For example, if you run generate-migrations-diff without changing your schema file whatsoever, you should get an empty up() function. However, the function that results for me has a changeColumn call for virtually every table in my database. Am i doing

Symfony: change database dynamically

こ雲淡風輕ζ 提交于 2019-12-29 07:01:02
问题 let's say I have 3 databases: prefix_db1 prefix_db2 prefix_db3 And I want to connect to them dynamically from the url like this http://localhost/my-project/web/app_dev.php/db1/books so I know which database to conenct to from the url (in this case prefix_db1 ) And basically the idea was to prepare a listener that will be fired with each http request , get the database name from the url and then override doctrin's params, something like this: Within services.yml : dynamic_connection: class:

problem understanding relation mapping in doctrine 2

喜夏-厌秋 提交于 2019-12-29 06:14:17
问题 I read official documentation and tons of threads but still do not find solution for my situation. My case is very basic. I have 2 entities: comments and keywords for them. One comment can have many keywords but each keyword is only for one comment. Keywords are not unique in keyword table. So i decided this is one-to-many relation. Tables structure are simply like follows: keywords id int(11) comment_id int(11) text varchar(30) comments id int(11) text text here is how i mapped them: /** *

Symfony doctrine auto_mapping Unrecognized

孤者浪人 提交于 2019-12-29 05:46:46
问题 I have added SonataUserBundle and it is giving error config.yml doctrine: orm: auto_generate_proxy_classes: "%kernel.debug%" naming_strategy: doctrine.orm.naming_strategy.underscore auto_mapping: true entity_managers: default: mappings: ApplicationSonataUserBundle: ~ SonataUserBundle: ~ error Unrecognized options "naming_strategy, auto_mapping, dql" under "doctrine.orm" 回答1: You are mixing shortened and full configuration. If you just want to use the default entity manager then you can place

'where not in' query with doctrine query builder

假装没事ソ 提交于 2019-12-29 04:12:25
问题 Im trying to reproduce this query: SELECT * FROM `request_lines` where request_id not in( select requestLine_id from `asset_request_lines` where asset_id = 1 ) in doctrine query builder, I am stuck on the where request_id not in(select I currently have: $linked = $em->createQueryBuilder() ->select('rl') ->from('MineMyBundle:MineRequestLine', 'rl') ->where() ->getQuery() ->getResult(); 回答1: You need to use query builder expressions, and this means you need access to the query builder object.

Zend Framework 1.11 with Doctrine 2 Integration

自古美人都是妖i 提交于 2019-12-29 03:10:12
问题 Could someone explain in detail how to integrate Doctrine 2 and Zend Framework 1.11? 回答1: There is a great video by Jon Lebensold about integrating D2 and ZF: Unit Testing Doctrine 2 - don't be misleaded by the title :) 回答2: I know this is a late inclusion but I just did this following the Zend webinar recording at http://www.zend.com/en/webinar/Framework/70170000000bSrG-webinar-zf-v-1-doctrine-v-2-20101214.flv (you need a (free) Zend account to view it). Ralph Schindler also has the slides