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

Documentum - Can child record be deleted without deleting the record in the relation

Hello I am completely newbie in Documentum but using DQL for some data extraction purpose. In dm_relation I have a relation which contains parent_id & child_id which are r_object_ids of 2 types(tables for me) I am facing a problem. It would be clear…
abhihello123
  • 1,668
  • 1
  • 22
  • 38
0
votes
1 answer

multiple where condition for checking NULL value in symfony1.4 and doctrine

I am using symfony1.4 and doctrine. I need to check a condition where the value is NULL. I nedd to write a query where status = 1 and start=NULL and end= NULL and estimated_time != NULL .I have tried with this but i am not able to get the result. …
Juice
  • 3,023
  • 6
  • 39
  • 66
0
votes
1 answer

Doctrine 2. How to calculate difference between two datetime fields in querybuilder

I have to following tables: Registration id int created datetime Activity id int startdate datetime Now I want to add this condition to my SQL query: (Registration.created + 7 days) <= Activity.startdate How can I do this in…
Rene Terstegen
  • 7,911
  • 18
  • 52
  • 74
0
votes
1 answer

Doctrine - strange moved parenthesis in the query

I have tested and done quite some research online, but still no luck. Did anyone ever encounter this problem ? Say, I have a doctrine query set up like: $q = Doctrine_Query::create() ->update('PckFolder') ->set('id_path', "CONCAT(?, RIGHT(id_path,…
Liangliang Zheng
  • 1,763
  • 11
  • 16
-1
votes
1 answer

How to make left join in dql Symfony

I would like to understand dql logic and i would like to create this kind of request. Bellow this is the SQL request i would like to do : SELECT titlemission,descriptionmission,onsetdate,deadline,budgetmission,prioritymission,company FROM…
Layer8
  • 1
  • 3
-1
votes
1 answer

Proper reuse of Doctrine's custom DQL function parameters to prevent "Positional parameter at index XXX does not have a bound value"

I am using Doctrine (Symfony project if that matters) and have custom DQL function FOO() to does some math using provided parameters. All is fine as long as my native implementation is using every provided parameter only once, but as soon as my…
Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
-1
votes
1 answer

MySQL query GROUP BY day/month/year

Is it possible to make a simple query to count the number of records I have in a specified time period like a year, month or day, having a field, like: public function group(){ $em = $this->getEntityManager(); $sub = $em->createQueryBuilder(); $qb…
imy
  • 7
  • 2
-1
votes
1 answer

Doctrine wrong results when using NOT IN with Postgresql and Symfony 4.4

I have 3 tables: contact, mailing_list and mailing_list_contact. Each contact can be subscribed to multiple mailing lists, recorded in mailing_list_contact. To fetch the total contact count subscribed to a mailing list i use this query: return…
Anthony G
  • 9
  • 3
-1
votes
1 answer

Transform SQL to DQL

I tried to transform a SQL function into DQL but i always have errors... I have 3 tables /** * @ORM\Entity(repositoryClass=ArticleRepository::class) */ class Article { /** * @ORM\Id * @ORM\GeneratedValue *…
Dunkeur
  • 57
  • 1
  • 7
-1
votes
1 answer

DQL with between - string date - PHP

I am trying to do a sql with between. The date data is entered first as a string. Any help with this question?
fatandaz
  • 117
  • 1
  • 1
  • 6
-1
votes
2 answers

Always get column in doctrine DQL

I want to automatically add columns (that are in all my entities) like 'lastEditedTime' and 'createdTime' to DQL queries but I don't know if it is possible? I already did a SQLFilter to add constraint, but didn't find a solution to add columns…
FindL
  • 495
  • 6
  • 25
-1
votes
1 answer

Unable to retrive parent records which does not have any child records MySQL

I have a table District(Parent table) and college (Child table) which are connected with one-to-many, one District may have multiple Colleges. Here district_id acts as a Foreign key in the College table. I am trying to retrieve districts which…
Hirein
  • 135
  • 5
  • 20
-1
votes
1 answer

Find the right DQL

I have some difficulties in DQL (and SQL !). I always write simple querys but now I need something more specific and I don't know how to do it. I have an entity User in OneToMany with my entity Program which is in OneToMany with my entity Exercice…
Micka Bup
  • 391
  • 1
  • 9
-1
votes
1 answer

Doctrine Partials. Why ManyToOne or OneToMany fields are not displayed in the results?

I'm trying to use partials on an entity which contains a ManyToOne or OneToMany relation. My DQL looks like this: SELECT partial a.{created, updated} , partial b.{id, value, entity} FROM App\Entity\DataSetting a INNER JOIN a.fileEntityValues b The…
Claudio Ferraro
  • 4,551
  • 6
  • 43
  • 78
-1
votes
1 answer

Add select COUNT events in common between the current user and the others in DQL query

I have this DQL query in Symfony 4 project, it does select all users who are registered in all the same events as current user $query = $this->_em->createQuery( "select u as user, er.dateRegistration from App:EventRegistration er left join…
hous
  • 2,577
  • 2
  • 27
  • 66