doctrine-orm

Doctrine 2 Cache: Can I use cache with Repository::find*()?

北战南征 提交于 2020-01-13 10:22:17
问题 I am new to caching. From the docs, I can use caching with queries, but what about methods like $em->find('Application\Models\project', 1); 回答1: If you search for an automatism, i think the awnser is no, their is no such thing. I was searching for something like this my self. You can wrap find(...) in a method of a service class, getProjectById($id) and do caching inside this method your self. But then you need a save() method too, to clear-cache for specific id after flushing. 回答2: As

Symfony and Doctrine making migration with no effect

笑着哭i 提交于 2020-01-13 09:59:06
问题 Doctrine is generating migration in symfony and nothing changes afer running the migration so during next diff it is the same. How to make Doctrine not generate this migration? Running the alter table command manually does not remove column collation. bin/console doctrine:migration:diff up $this->addSql('ALTER TABLE session CHANGE sess_id sess_id VARCHAR(128) NOT NULL'); down $this->addSql('ALTER TABLE session CHANGE sess_id sess_id VARCHAR(128) NOT NULL COLLATE utf8_unicode_ci'); Table looks

Symfony does not remove entity from collection

雨燕双飞 提交于 2020-01-13 08:18:48
问题 I know there are loads of posts on this topic in general. Unfortunately those mostly deal with the actual persist-operation to the database. In my case I have a problem that happens before the persist-operation: I have a form with a (Doctrine) persistenceCollection of entities. You can remove "objects" from the DOM via javascript. After submit, when handleRequest is called on the form, the function in my entity is called which removes the entity from the collection in the object itself, and

Doctrine2 Order By before Group By

流过昼夜 提交于 2020-01-13 06:15:13
问题 I am having issues implementing a sub-select solution for ORDERING a resulting dataset before the GROUP BY reduces it. Normally, in SQL you would do a sub-select: SELECT * FROM ( SELECT * FROM a_table order by a_table.timestamp desc ) as table_tmp group by userId However, I am having difficulty implementing this in DQL. Can anyone point me in the right direction please? My query is more complex than this and I assume I JOIN other tables through 'table_tmp' and in the outer SELECT. Thanks. 回答1

Doctrine 2 subquery

霸气de小男生 提交于 2020-01-12 05:29:48
问题 I want to implement a subquery using the query builder but I'm not understanding the syntax. I'm dealing with a locations table that has entries that can be cities, states or zip codes depending on the location type set. I want to get all locations that are in a certain state and take out any that are city type and have a population below a certain amount. $qb->select('l') ->from('Entity\Location', 'l') ->where('l.state = :state') ->setParameter('state', 'UT') ->andWhere('...don't know what

Doctrine 2 subquery

吃可爱长大的小学妹 提交于 2020-01-12 05:29:02
问题 I want to implement a subquery using the query builder but I'm not understanding the syntax. I'm dealing with a locations table that has entries that can be cities, states or zip codes depending on the location type set. I want to get all locations that are in a certain state and take out any that are city type and have a population below a certain amount. $qb->select('l') ->from('Entity\Location', 'l') ->where('l.state = :state') ->setParameter('state', 'UT') ->andWhere('...don't know what

Doctrine2 Ignore table of database

♀尐吖头ヾ 提交于 2020-01-12 04:47:10
问题 I'm using Doctrine 2 and I want to generate an ORM of my database but I don't want select all tables of the db. For example, in this db : Table 1 has no primary key Table 2 is normal I want to choose ONLY Table 2 with this command: doctrine:mapping:convert --from-database yml ./src/Application/TestBundle/Resources/config/doctrine/metadata/orm --filter="Table2" I have an error : Table Table_1 has no primary key. Doctrine does not support reverse engineering from tables that don't have a

Pagination using Doctrine and ZF2

亡梦爱人 提交于 2020-01-11 19:42:30
问题 i am trying to implement Pagination Using ZF2 and Doctrine. What i am trying to do here is to fetch data from An associated table lets say 'xyz'. Where as my categories table is doing one to many self referencing on its own PK. MY catgories tables has following feilds ID (PK) Created_at Category_id (self referencing PK) My XYZ table lets say it is called Name table has ID (PK) Category_id(FK) name Detail This is what i am trying to do to fetch data public function allSubcategories($id,

Pagination using Doctrine and ZF2

旧街凉风 提交于 2020-01-11 19:40:03
问题 i am trying to implement Pagination Using ZF2 and Doctrine. What i am trying to do here is to fetch data from An associated table lets say 'xyz'. Where as my categories table is doing one to many self referencing on its own PK. MY catgories tables has following feilds ID (PK) Created_at Category_id (self referencing PK) My XYZ table lets say it is called Name table has ID (PK) Category_id(FK) name Detail This is what i am trying to do to fetch data public function allSubcategories($id,

What is the owning side and inverse side in the doctrine 2 doc example

走远了吗. 提交于 2020-01-11 17:43:52
问题 On this page of association mapping, there's an example in the manytomany section. But I don't understand which entity (group or user) is the owning side. http://docs.doctrine-project.org/en/2.0.x/reference/association-mapping.html#many-to-many-bidirectional I've put the code here too <?php /** @Entity */ class User { // ... /** * @ManyToMany(targetEntity="Group", inversedBy="users") * @JoinTable(name="users_groups") */ private $groups; public function __construct() { $this->groups = new