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

Translate SQL query to Doctrine DQL (join and group by)

I need to translate SQL query to Doctrine DQL. SELECT g.id, g.round_id, g.score, g.prize_id FROM game g INNER JOIN ( SELECT prize_id, MAX(score) score FROM game GROUP BY prize_id ) g2 ON g.prize_id = g2.prize_id AND g.score =…
-1
votes
1 answer

Apply multiples conditions with Doctrine Query Language

In my database, i have a column "refused", she can have 0 or 1 or NULL value. I want to get only rows with 0 and NULL values. I tried this : ->andWhere('b.refused IS NULL') It's okay, but if i want to get the 0 values too that's not working…
Tony S
  • 491
  • 6
  • 26
-1
votes
1 answer

What does ':'(colon) mean in dql?

I'm working on a server that uses doctrine orm, and i came across the following function: public function showForJustWhoCanSee() { $subquery = $this->em->createQueryBuilder(); $subquery->select('userSignature') …
Bruno Souza
  • 198
  • 1
  • 12
-1
votes
1 answer

Symfony 3 - I can't use lower in DQL function

I've a function and i would like put my attributes to lower : public function getHomonymes($nom, $prenom) { $queryBuilder = $this->createQueryBuilder("u") ->select("count(u.id") ->where("lower(u.nom) = :nom") …
Agar io FR
  • 53
  • 13
-1
votes
2 answers

Converting a Dataease 4.23 DQL database into a SQL database

So I have a DataEase DOS 4.23 database, which I have full access to open and look at, and I'm looking to see if I can somehow convert this into a MSSQL or PGSQL (or any modern SQL, really) database. I've looked through this software, and I can't…
Kwahn
  • 446
  • 2
  • 12
-1
votes
1 answer

Symfony doctrine DQL Functions give's Notice: Undefined index on alias column name

I am trying call a function created function in Entity Repository public function getBillGroupByDate($dateStart, $dateEnd) { return $query = $this->createQueryBuilder('d') ->select('count(d) as nb, SUBSTRING(d.created, 1, 10) as…
-1
votes
1 answer

Doctrine -Matching entities on common attribute (OneToMany & ManyToMany)

I am trying to match two entities based on a set of criteria but I can't seem to make it work in this particular case. For the purpose of the example, let's say I have: Article with N tags Category with 1 tag What I would like to do would be to, in…
TPouliquen
  • 114
  • 2
  • 14
-1
votes
1 answer

I made custom query with DQL and the object doesn't see that method

When I was learning Symfony, I got a problem with the custom query in DQL, there is a link to the doc: https://symfony.com/doc/current/doctrine.html#querying-with-dql-or-sql I made the same function like this:
Reedy
  • 3
  • 3
-1
votes
2 answers

From SQL to DQL

I want to change this SQL query : (i'm using a bundle) (Evenement is an entity and evenement_evenement is the result of self-referencing many to many of evenement) SELECT * FROM evenement e natural JOIN evenement_evenement ee WHERE e.id…
-1
votes
1 answer

CASE WHEN with LEFT JOIN?

I want to select the left join table depending on a value from other table. So I tried this, but not working: CASE WHEN c.catId LIKE "%s%" THEN LEFT JOIN AppBundle:newspaper_subcategories cat WITH c.catIdShort = cat.id ELSE LEFT JOIN…
M. F
  • 77
  • 9
-1
votes
1 answer

Symfony/doctrine - DQL order by parameter not defined

can anyone tell me why this code does not work : $sort = 'u.username'; //test $dql = 'SELECT u, p FROM GPAuthBundle:User u JOIN u.profile p WHERE ( u.username LIKE :username ) AND ( u.username LIKE :search OR p.name LIKE :search ) …
-1
votes
2 answers

Adding If condition to where clause in DQL / Symfony 3

I've a doctrine entity with two variables $price & $price_new mapped to mysql table with same column name. $price contains legacy values and $price_new contains new values. I want to write a query which checks if $price_new > 0 then apply where on…
Faizan
  • 389
  • 3
  • 10
-1
votes
2 answers

Query to Delete foreign key in Symfony

Can someone help me with this, to create a query that if the user tries to delete a foreign key it gives them an error rather than using an exception. public function findByStudent($studentid, $id){ return $this->getEntityManager() …
buju lloyd
  • 15
  • 7
-1
votes
1 answer

Dql in Query Builder

I have been working some days with a dql problem. In my model, y have 2 entities (machine and instance). Is a one-to-many relation, so a machina could have many instances, and an Instance only can have 1 machine. Now, I want to get all machines…
Angel
  • 1,970
  • 4
  • 21
  • 30
-1
votes
1 answer

how to make a dql request with table database are not an entity

I would like to understand why my DQL request doesn't work. I've to entity : books(ouvrages) and authors(auteurs), there is many to many relation, so in my database a join table is create books_authors (ouvrages_auteurs) with reference "id" of each…
Tirkal
  • 43
  • 8