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

Symfony 2: LIMIT Doctrine LEFT JOIN

I have a question about left join in doctrine in Symfony 2.7. Example code: public function test($id, $offset, $limit) { $build = $this->createQueryBuilder('building'); $build ->addSelect('users', 'numbers') …
Car
  • 13
  • 6
1
vote
1 answer

How to project more than one value with doctrine mongodb query builder selectElemMatch

I have the following kind of data in my mongo database. The property "values" consists of an array of attributes. "values" is a property of a product, which also has some other properties like "normalizedData". But the structure of "values" is what…
Micha
  • 523
  • 10
  • 26
1
vote
1 answer

How to Hydrate custom query in Symfony/Doctrine

After performing a custom query using $DBH = Doctrine_Manager::getInstance()->connection()->getDbh(); $PDO = $DBH->prepare("mysql query"); $PDO->execute(); How do I return model objects instead of record arrays? EDIT I got mine working by using…
whamsicore
  • 8,320
  • 9
  • 40
  • 50
1
vote
0 answers

Doctrine (Symfony) very slow select with many left join

Doctrine very long time (126.04 ms) makes a query and returns data if query contains select with many (6) LEFT JOIN and returned many data (more when 1200 rows) My query: https://gist.github.com/Neokortex/218463a50f57529d6e0caf9b82fc4aa9 A week ago…
Alexander
  • 85
  • 1
  • 7
1
vote
1 answer

Is there anyway to pass dql to doctrine criteria

I am using Symfony3 framework, and I have user entity, and file entity. I wanted to present in sonata administration user list with sum of all size files which are uploaded by user. When I want to make that field sortable I am getting…
1
vote
1 answer

Symfony2 DQL Update query with Many to Many

I have three tables "category", "product" and "product_category". First two tables are created from two entity Category and Product. Third table "product_category" is auto generated by framework doctrine console command. Now I can get (fetch)…
Kiran
  • 1,176
  • 2
  • 14
  • 27
1
vote
1 answer

Doctrine collection altered by other fetch query

I'm new to Unit testing in symfony, and i'ts being pretty annoying, since I experienced one problem, which took me 1 hour to identify. Hopefully, you guys will know why this happens. So I'm testing my "search" method : class TadalistTable extends…
Julien
  • 9,312
  • 10
  • 63
  • 86
1
vote
2 answers

How to convert this query to doctrine DQL

SELECT apntoken,deviceid,created FROM `distribution_mobiletokens` as dm WHERE userid='20' and not exists ( select 1 from `distribution_mobiletokens` where userid = '20' and deviceid = dm.deviceid and created > dm.created …
Joseph Astrahan
  • 8,659
  • 12
  • 83
  • 154
1
vote
0 answers

Symfony 2 multi associated entity with self-referencing and join

I try to make a classic comment-multilevel replies system : Comment 1 Reply 1-1 Reply 1-2 Reply 1-3 So I have created 2 entities Comment and Reply defined by : class Comment { [...] /** *…
Kyoshi
  • 11
  • 2
1
vote
1 answer

Accessing values from a joined query from Doctrine with Twig

I have a problem with accessing the values from a joined query. I built a query in a Repository that joins/left joins tables. To make the following code a bit understandable: I have an appointment. This appointment is part of an event and event is…
kruben
  • 142
  • 2
  • 14
1
vote
1 answer

Serialize a PHP object (Doctrine Query)

I'm trying to serialize a Doctrine_query object in Symfony : var_dump(serialize($this->pager->getQuery())); The result is : string(2) "N;" What am I doing wrong?
Tiois
  • 1,519
  • 1
  • 15
  • 32
1
vote
3 answers

Doctrine Many To Many Inner Join

I'm trying to get manyToMany relationship with Doctrine and symfony. I'm new at Doctrine and Symfony. I came from Zend framework. I've created the 3 tables: Post, PostCategory and junction table PostToCategory as you can see below. My goal is to…
1
vote
0 answers

Doctrine Join - Error: Class 'alias' is not defined

I'm making a query using the QueryBuilder object from Doctrine. In that query I have a join which I don't know why, gives me an error saying that the alias (fe) for one of the tables (F_Expenses) is not defined. In SQL, my query would looks like…
Drumnbass
  • 867
  • 1
  • 14
  • 35
1
vote
1 answer

Joining 2 results in Doctrine throws error

I am trying to JOIN 2 queries in DQL but I am getting an error which says, [Semantical Error] line 0, col 114 near '(select u.email': Error: Class '(' is not defined. I have gone through …
notnotundefined
  • 3,493
  • 3
  • 30
  • 39
1
vote
2 answers

How to use with Doctrine the OR function when having multiple fields?

I'm making an inlog form where the user can decide to use this username or email address in combination with its password. So normally it would something like: ((username OR email) AND password) in SQL. Used the following controller code only don't…
Tom
  • 1,547
  • 7
  • 27
  • 50