dql

Doctrine where in with Doctrine_Query

二次信任 提交于 2020-01-15 07:47:10
问题 is it possible to make : $q->createQuery('q') ->whereIn('q.id', $q2) Where $q2 is an other Doctrine_Query object. Because my subquery is complex and I don't want to write it in SQL... 回答1: Unfortunately, according to the Doctrine API documentation, you can't pass another query object to whereIn() , so you will have to fetch your ID-s beforehand and pass them in an array. Be careful though, because if you pass an empty array, then there will be NO FILTERING for those ID-s. In other words: it

Doctrine DQL RIGHT JOIN?

ε祈祈猫儿з 提交于 2020-01-13 12:19:12
问题 Is it possible to do a RIGHT OUTER JOIN in Doctrine 2 DQL? 回答1: As far as I know, there is still no way to do that in DQL, and the reason might be that it does not make much sense from an ORM perspective, according to one of the lead developers. Nevertheless, the feature request, although very old, is still open; so it might be implemented in the future. 来源: https://stackoverflow.com/questions/7957987/doctrine-dql-right-join

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

How can I order by NULL in DQL?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-10 20:04:29
问题 I'm building an app using Symfony2 framework and using Doctrine ORM. I have a table with airlines for which some IATA codes are missing. I'm outputting a list, ordered by this IATA code, but I'm getting the undesirable result that the records with null IATA codes are sorted at the top. In MySQL this is simple enough to do, with ORDER BY ISNULL(code_iata), code_iata but I'm clueless as to what the equivalent would be for DQL. I tried $er->createQueryBuilder('airline')->orderBy('ISNULL(airline

Symfony2 and Doctrine: Many-to-many relation using query builder

五迷三道 提交于 2020-01-06 15:11:33
问题 I have 2 entities: User and Archive. The user entity has, among others, two properties: /** * @ORM\OneToMany(targetEntity="My\ApplicationBundle\Entity\Archive", mappedBy="user") **/ protected $archives; /** * @ORM\ManyToMany(targetEntity="My\ApplicationBundle\Entity\Archive", inversedBy="users") * @ORM\JoinTable(name="collection") **/ private $collection; and the Archive entity: /** * @ORM\ManyToOne(targetEntity="My\UserBundle\Entity\User", inversedBy="archives") * @ORM\JoinColumn(name="user

JOIN DQL (symfony2) multiple joins between two tables

拈花ヽ惹草 提交于 2020-01-06 14:50:11
问题 I have a problem in my DQL query. I have a table which has 3 foreign keys userId, userRId and userAId. Two of those foreign keys may be NULL. I want to join all the foreign keys in the query but i don't know how to join two or three foreign keys between the same tables. (see query ) Could somebody give me some ideas?? **TABLE A** id userId userRId userAId 1 2 NULL NULL 1 2 1 NULL 1 2 NULL 1 **TABLE USER** userId name 2 xxxx 1 xxxx The DQL query: "SELECT FROM nasyBundle:A a JOIN a.userId u , a

how to create a new ACL in Documentum with DQL

不打扰是莪最后的温柔 提交于 2020-01-06 11:10:26
问题 I am doing a Java project connected to Documentum data storage and I need to create a ACL using DQL . Any idea on how can I do that ? I've found the following in my researches in EMC forums but I dont really understand how to use it ? create,c,dm_acl set,c,l,object_name your_acl_name set,c,l,owner_name dm_dbo grant,c,l,dm_world,1 // Granting Permission revoke,c,l,dm_world,execute_proc,change_permit // Revoking permission grant,c,l,your_admin,7,execute_proc,change_permit // granting permission

Delete row from related entity in many to many relationship in Doctrine2

一曲冷凌霜 提交于 2020-01-05 07:41:22
问题 I have this entity: class FabricanteProductoSolicitud { use IdentifierAutogeneratedEntityTrait; /** * @ORM\ManyToOne(targetEntity="\AppBundle\Entity\FabricanteDistribuidor") * @ORM\JoinColumn(name="fabricante_distribuidor_id", referencedColumnName="id") */ protected $fabricante_distribuidor; /** * @ORM\ManyToOne(targetEntity="\AppBundle\Entity\ProductoSolicitud") * @ORM\JoinColumn(name="producto_solicitud_id", referencedColumnName="id") */ protected $producto_solicitud; /** * @ORM\ManyToMany

Doctrine: Group by date ranges

时光总嘲笑我的痴心妄想 提交于 2020-01-05 04:26:25
问题 In my Symfony app I have an entity 'Project' which contains two fields: 'createdOn' (type = date) and 'individual'. An individual can occur multiple times in 'Project'. _created_On_|_individual_id 2012.12.01 | 3 2012.12.24 | 5 2013.01.10 | 9 I'm trying to build a query to count all distinct individuals grouped by 'createdOn' in such a way, that I get results sorted by month. And it must be possible to set a date range for the query. My query so far: 'SELECT p.createdOn, COUNT (DISTINCT p

Cannot select entity through identification variables without choosing at least one root entity alias

北城以北 提交于 2020-01-02 04:10:31
问题 Ads entity is described by geographic information: Country> Region>County . The Ads entity is only linked with County . Consequently, retrieving Ads by countries will require us joining entities twice. My goal is counting the number of Ads for a given country. For that, I tried this DQL query but without success: public function getMotorsAdsCountByCountry($slug){ $qb = $this->_em->createQueryBuilder() ->select("m.id, COUNT(m.id) AS cnt") ->from("MinnAdsBundle:MotorsAds", "m") ->join("m.county