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
-1
votes
1 answer

Multiple On conditions in Doctrine2 Left Join

I have RATE and BRANCH_CURRE table. I want to perform left join operation (joining branch to rate) in Doctrine Query Language (DQL). My SQL Query is: SELECT r.id rid ,r.TIME rtime ,r.rate_candidate ,r.exchange_rate ,r.branch …
Rman
  • 1
  • 1
  • 5
-1
votes
1 answer

for cycle doesn't work in my .twig file and fails to show items

I'm using this .twig file to show the result of a query: {% extends 'base.html.twig' %} {% block body %} {{parent()}}
{% for eq in equipos %} …
xXNukem
  • 21
  • 1
  • 6
-1
votes
1 answer

SQL query convert to DQL (Doctrine for Symfony2)

How can I use this query in DQL (Symfony2): SELECT id FROM user WHERE DATE_FORMAT( birth_date ,'%m-%d') = DATE_FORMAT( NOW() + INTERVAL 7 DAY ,'%m-%d') I use beberlei/DoctrineExtensions, I added this is my config: orm: dql: string_functions: …
Tiberiu
  • 418
  • 1
  • 3
  • 12
-1
votes
1 answer

How could I sort the array of entity objects returned by this doctrine query?

For the below route I want to return a list of Events that are on or after the current date - however I'm having problems as I'm only aware of how to do either: Return all objects sorted by date Return all objects after 'today' ...but I can't work…
Bendy
  • 3,506
  • 6
  • 40
  • 71
-1
votes
1 answer

Case condition is not working

What I need: I need to check if eventvisitor.published is 1 then increment by zero else eventvisitor is equal to 0. mysql query SUM( CASE WHEN eventvisitor.published =1 THEN…
user2818060
  • 835
  • 5
  • 19
  • 41
-1
votes
1 answer

Doctrine 2 DQL Subquery

I'm trying to use a Subquery in the FROM Block via Doctrine 2.3 DQL. Everytime im run this, getting following error [Semantical Error] line 0, col 839 near '(SELECT ': Error: Class '(' is not defined. This is my current DQL Code $query =…
darthsoup
  • 428
  • 3
  • 8
-1
votes
2 answers

MySql query works but syntax error in DQL

This query in mySql gives me the result I want: SELECT reportcolumn.name FROM report LEFT Join reportcolumn ON report.id=reportcolumn.reportid WHERE report.title = "Report" However, when I try to write it as DQL, I get a syntax error. …
manisha
  • 577
  • 2
  • 4
  • 22
-1
votes
1 answer

Accessing a Custom Query in Symfony2 Repository

This is my query for getting a random product: public function getRelatedProducts() { $em = $this->getDoctrine()->getManager(); $max = $em->createQuery('SELECT MAX(p.id) FROM GlassShopBundle:Product p')->getSingleScalarResult(); …
dsuma
  • 1,000
  • 2
  • 9
  • 30
-1
votes
1 answer

Doctrine\ORM\Query\QueryException - Error: Expected end of string, got 'WHERE'

There is a function I'm using to get next photo in gallery: $q = "SELECT i FROM GalleryModule\Image i WHERE i.id = (SELECT MIN(p.id) FROM GalleryModule\Image p WHERE p.id > :id ORDER BY p.position, p.id DESC) WHERE i.gallery = :gallery"; $query…
peter.o
  • 3,460
  • 7
  • 51
  • 77
-1
votes
1 answer

Multiple condition inside a DQL query

I need to build a SQL/DQL query for my dating website, which retrieve all users with some matched fields like sex, age, location and 3 interests. I don't know how to create multiple condition inside my DQL Query. I've started with something like…
Nizar B.
  • 3,098
  • 9
  • 38
  • 56
-1
votes
2 answers

Symfony2 repository query not working

I am developing an application using Symfony2 and DQL for building some queries in the repositories. I have the next code in the controller: $emGalPak = $this->getDoctrine()->getEntityManager(); $OsatugabeKop =…
Haritz
  • 1,702
  • 7
  • 31
  • 50
-2
votes
1 answer

How to use DATE_ADD in Doctrine's Querybuilder?

I am working on a repo to find all booking done in a reservation during a period. I have a check-in date and a number of nights they stay. /* * @return array */ public function findAllByHotelIdAndDate(int $id, \DateTime $date) { $qb =…
Sam Bath
  • 113
  • 9
-2
votes
3 answers

Stuck in building MySQL query

Given an example of table: id | item_id | user_id | bid_price ---------------------------------- The task is to select rows with minimum bid_price for each item_id in the provided set. For example: item_id = [1, 2, 3] - so I need to select up to…
Sergej
  • 2,030
  • 1
  • 18
  • 28
-2
votes
1 answer

Symfony [Semantical Error] 'id' is not defined

your learning Symfony neighbor here, I am calling a method from my controller through Ajax on a select change. I manage to get the data I send to the controller, but I'm struggling as I try to make a Select with the data I get, for some reason, no…
Nolan.K
  • 185
  • 2
  • 18
-2
votes
1 answer

Convert sql to doctrine symfony or DQL

hello i have 2 many to one relation in database and use sql query is ok but can`t convert query mysql to dql or querybuilder please help me SELECT * FROM `resturant` LEFT JOIN `food` ON `resturant`.`id` = `food`.`resturant_id` WHERE…
Kaveh Yzd
  • 119
  • 1
  • 12
1 2 3
86
87