Questions tagged [dql]

Doctrine Query Language (DQL) is an Object Query Language created for helping users in complex object retrieval.

Summary

DQL stands for Doctrine Query Language and is an Object Query Language derivate that is very similar to the Hibernate Query Language (HQL) or the Java Persistence Query Language (JPQL).

In essence, DQL provides powerful querying capabilities over your object model. Imagine all your objects lying around in some storage (like an object database). When writing DQL queries, think about querying that storage to pick a certain subset of your objects.

Questions

  • How to write DQL statements to achieve a particular SQL statement?
  • Why will a DQL statement not work as expected?

More Information

To learn more about DQL visit

Doctrine 1.2
http://www.doctrine-project.org/projects/orm/1.2/docs/manual/dql-doctrine-query-language/en#dql-doctrine-query-language

Doctrine 2.0
http://www.doctrine-project.org/docs/orm/2.0/en/reference/dql-doctrine-query-language.html

1296 questions
0
votes
2 answers

Symfony2, dql is not working with REPEAT function

public function mpttLocationList() { $q = $this->_em->createQuery(" SELECT CONCAT(REPEAT('.', COUNT(parent.region_name) - 1), node.region_name) AS name FROM ViveListingBundle:region_redefine AS node, …
0
votes
1 answer

Is it posible to hydrate dates as DateTime in mixed queries in doctrine2?

I have a mixed query like this: SELECT e, j.date_field FROM AcmeBundle:SomeEntity e JOIN e.joined_entity j The query returns an array with the object and a string with the date, but I need dates hydrated as DateTime instances. Is it posible to…
Jens
  • 5,767
  • 5
  • 54
  • 69
0
votes
0 answers

How to use DQL for querying relationship table

So far my DQL is working fine if i use man entity table. but i have one query where i need to access the relationship table like Entities are User , Tasks UserTasks is relation many to many This is my SQL which is working fine SELECT A.name , A.id…
Mirage
  • 30,868
  • 62
  • 166
  • 261
0
votes
1 answer

Fetching array data from database in symfony2

I have a table "config" with three fields ------------------ id | name | value ------------------ 1 | na1 | va1 2 | na2 | va2 3 | na3 | va3 . | ... | ... I need to fetch the above data to an array "$confData" as given below $confData…
Mohammed H
  • 6,880
  • 16
  • 81
  • 127
0
votes
2 answers

Convert mysql query with date_format in doctrine dql

How can I convert this query in doctrine? select distinct date_format(data_fine, '%d/%m/%Y') from calendario Thanks for your help.
user1565792
  • 1
  • 1
  • 1
0
votes
1 answer

Doctrine 2 edit DQL in entity

I have several database tables with 2 primary keys, id and date. I do not update the records but instead insert a new record with the updated information. This new record has the same id and the date field is NOW(). I will use a product table to…
SImmenga
  • 1
  • 1
0
votes
1 answer

JOIN DQL (symfony2) multiple joins between two tables

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…
nasy
  • 549
  • 2
  • 9
  • 18
0
votes
1 answer

How to update field based on another field in table in Doctrine2?

I have table with two columns: price and constant. I would like to run update on all entries in table to update price based on constant * coefficient. How could I do such query?
pixel
  • 24,905
  • 36
  • 149
  • 251
0
votes
1 answer

COUNT query on a boolean column with DQL

I have a "simple" question whose answer seems not to be in the official DQL docs. Given an application built with Doctrine2, suppose to have a boolean column (let say B for entity Foo), how to count the number of rows such that the value in B is…
JeanValjean
  • 17,172
  • 23
  • 113
  • 157
0
votes
0 answers

Optimizing Doctrine WHERE Clause with Regex

See the Below Doctrine Query: SELECT values, orgunit, form FROM Values values INNER JOIN values.orgunit orgunit INNER JOIN values.form form INNER JOIN orgunit.orgunitStructure orgunitStructure WHERE…
mukulu
  • 161
  • 1
  • 6
0
votes
1 answer

Doctrine 2 ORDER BY the field of a joinTable

I have an Entity defined like this: Munkatars: id: id: type: integer fields: nev: type: text [...] manyToOne: vezeto: targetEntity: Munkatars inversedBy:…
GergelyPolonkai
  • 6,230
  • 6
  • 35
  • 69
0
votes
1 answer

Optimize DQL with double join

I have such a structure: single profile can attend do several studies and for each study there is statute field which is foreign key to study_statute. In HTML in each row I need to show information for profile: profile.name, profile.study.field,…
koral
  • 2,807
  • 3
  • 37
  • 65
0
votes
1 answer

Doctrine 2 DQL - nest expressions and functions in the QueryBuilder

I have found DoctrineExtensions module that has implement some useful MySQL functions. But I think my problem is a general one. How would you pass another mysql expression as a parameter into a function? If I had 2 columns updated_at which is a…
gawpertron
  • 1,867
  • 3
  • 21
  • 37
0
votes
1 answer

Event-based extension of query builder in Doctrine repository

I have a Doctrine entity Page which is loaded by module Foo. The page is a nested set provided by the Gedmo Doctrine Extension. The module Bar has another model Metadata, 1:1 related to a page. I would like to join the metadata directly when Foo…
Jurian Sluiman
  • 13,498
  • 3
  • 67
  • 99
0
votes
1 answer

doctrine 2 join association not found

I've followed some of the questions on this site and still haven't been able to figure out what's wrong with my setup. I've been been stumped for awhile. Sorry if this is a basic mistake, I'm still new to Doctrine. Thank you. The error I get…
user594044
  • 255
  • 2
  • 4
  • 13