Questions tagged [doctrine-query]

Doctrine Query Language (DQL) is one of the Doctrine 2 ORM key features, it is the option to write database queries in a proprietary object oriented SQL dialect.

Doctrine Query Language (DQL) is one of the Doctrine 2 ORM key features, it is the option to write database queries in a proprietary object oriented SQL dialect. Inspired by Hibernates HQL, this provides developers with a powerful alternative to SQL that maintains flexibility without requiring unnecessary code duplication.

More about Doctrine ORM you could fine on the project site, here.

370 questions
0
votes
2 answers

Symfony3.4 / Doctrine : subquery in FROM Clause : Error: Class 'SELECT' is not defined

I'm working on a Symfony 3.4 project and I'm trying to translate an sql query to DQL query but I get an Issue. Mysql Query: select sum(montant_paye) from (select montant_paye from vente where client_id = 1 and montant_paye >…
0
votes
0 answers

Symfony2 query to show event happening today then the rest of them DESC order

Can someone help me make this symfony doctrine query to return first the event happening today and then the rest of events in DESC order? Here what I have now: public function getCompanyQuery($company, $adId) { $qb =…
0
votes
1 answer

Add a select based on a conditional to doctrine query builder

How can you add a select based on a conditional to the doctrine query builder? I'd like to replicate SQL similar to this: select p.id, p.id = 3 as first_result from problem p order by first_result desc, p.id
Geoff Maddock
  • 1,700
  • 3
  • 26
  • 47
0
votes
0 answers

Doctrine querybuilder - select query with a join for many to many in doctrine

I am trying to create a select query in order to make a searchable index. The problem is, whenever I select an attribute for the joined class, I only receive the first result of all possible results. I tried to implode the array, but no success so…
Dirk J. Faber
  • 4,360
  • 5
  • 20
  • 58
0
votes
1 answer

Get flat array when making mutliple selects in Doctrine

I have a query that fetches some information from a table AND the count of related objects from another table. I have trouble expressing it in DQL, so it will return a flat array. This example fetches the school, the name of the school and the…
tobias47n9e
  • 2,233
  • 3
  • 28
  • 54
0
votes
1 answer

DQL and MAX function call as a CONCAT argument

I have a repository function having the following instructions: $QB = $this->_em->createQueryBuilder(); $QB ->addSelect("CONCAT(dsub2.dagId, MAX(tsub2.executionDate))") ->from(TaskInstance::class, 'tsub2') ->join('tsub2.dag', 'dsub2') …
Stphane
  • 3,368
  • 5
  • 32
  • 47
0
votes
1 answer

Convert query to doctrine DQL

I have pretty big MySQL query for performance optimization I'm adding subqueries inside a join statement. With raw SQL all working fine. Here is the query: SELECT campaigns.id, campaigns.name, CONCAT(users.id, ' ', users.email) AS…
Bogdan Dubyk
  • 4,756
  • 7
  • 30
  • 67
0
votes
0 answers

Semantical Error line 0, col 58 near '': Error: Class X has no field or association named Y

i ve searched for 2 days for an answer but i can't find it, please help me guys ! :) I Have this : In Entity Bon: /** * $entreprise. * * * * @ORM\ManyToOne(targetEntity="Soraya\UserBundle\Entity\Entreprise", inversedBy="bons") *…
0
votes
1 answer

Doctrine leftJoin entity is not a child of the main entity

I have huge query with many leftJoins. All the leftJoin, except of one, is associated in the entities. The one, which does not gets every time an own entry, if I use the array hydration mode. Basically, I am using Shopware and this query is part of…
alpham8
  • 1,314
  • 2
  • 14
  • 32
0
votes
1 answer

How to change the selected name of a doctrine querybuilder expression inside of a select

I am trying to change the returned array from a doctrine query from: ['city' => 'Warsaw', '1' => '2'] to: ['city' => 'Warsaw', 'count' => '2'] My query looks like this: $queryBuilder = $this->createQueryBuilder('geo'); $queryBuilder->select([ …
tobias47n9e
  • 2,233
  • 3
  • 28
  • 54
0
votes
1 answer

Notice: unserialize(): Error at offset 473 of 578 bytes while executing doctrine query

We are trying to execute the below doctrine query and its throwing unserialize(): Error at offset 473 of 578 bytes. Doctrine Query: SELECT p FROM MyCompanyBundle:Person p WHERE p.dateOfExit IS NULL AND (p.passportCountry IS NULL OR…
0
votes
1 answer

Order pagination result in Symfony 2

I have a question about the order in the pagination in Symfony 2.7. Before we used pagination we used the PHP function usort to sort some things. But my question now is how could we implement the usort in the doctrine query with the same order like…
Car
  • 13
  • 6
0
votes
1 answer

Query inside NOT IN statement Doctrine

I found this sentence in the code: $dql = <<
jjoselon
  • 2,641
  • 4
  • 23
  • 37
0
votes
1 answer

Symfony Creof FUNCTION mydbname.distance doesn't exist

I'm trying to use the Creof bundle and its Distance function. When I execute the following code, I get the following exception: public function getMapDecorator(array $requestInformation, $type) : MapDecorator { $queryBuilder =…
Etienne Noël
  • 5,988
  • 6
  • 48
  • 75
0
votes
1 answer

How to use PostgreSQL COLLATE modifier in Doctrine

I use Doctrine and PostgreSQL database in my project and I would like to make it translatable. The problem is that I would like to sort some strings correctly related to the selected language customs. Eg. in Czech language there is the letter "CH"…