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

Doctrine: How to join on a specific row?

Lets take a look at my classes. As you can see, Model has Batteries, which is a ManyToMany relationship. A Model also has 1 Battery which is one of the Batteries with the highest count. I want to select all the models for which Battery(not one of…
Robin Dijkhof
  • 18,665
  • 11
  • 65
  • 116
0
votes
1 answer

Doctrine create function from another

I have the following function that counts the unanswered questions: public function getUnansweredQuestions(Company $company){ $qb = $this->createQueryBuilder("q"); $andX = $qb->expr()->andX(); …
dimvcl
  • 289
  • 1
  • 3
  • 13
0
votes
1 answer

'Invalid parameter number: number of bound variables does not match number of tokens' Symfony

I'm working on a symfony project entity with query builder. When I try to run this function I get this issue. Invalid parameter number: number of bound variables does not match number of tokens public function json_filterAllproductsAction() { …
vimuth
  • 5,064
  • 33
  • 79
  • 116
0
votes
1 answer

Doctrine create subquery with bound params

I am trying to construct a query that will basically pull all entries whose id's have 2 particular entries in another table so I am trying the below: $query = $this->createQuery('e'); $subquery1 = $query->createSubquery('sea') …
mixkat
  • 3,883
  • 10
  • 40
  • 58
0
votes
2 answers

how to get rid of primary column in doctrine queries

Doctrine always includes an ID column in a query, for example: $new_fees = Doctrine::getTable('Stats')->createQuery('s') ->select('s.sid')->where('s.uid = ?', $this->uid) ->andWhere('s.operation = ?',…
Jacek Krysztofik
  • 1,266
  • 1
  • 13
  • 29
0
votes
1 answer

Retrieve related objects with Doctrine and Symfony

I searched for a long time, but I don't manage to retrieve two related object in one query. I am using Doctrine and Symfony (uses Doctrine by default). Here is a part of my schema.yml: Member: columns: ...some fields... Report: columns: …
Cyril
  • 1,649
  • 1
  • 17
  • 32
0
votes
1 answer

Symfony2 objects

I am having problem in getting data from doctrine object. When I use findOne(id) and try to access any variable like $result->getVariable() it works fine. But as soon as I use doctrine query builder and add some conditions, it says Attempted to…
Salman
  • 69
  • 6
0
votes
1 answer

Convert nested array into string array for Doctrine where query

Whats the simplest way to convert the following nested array into a simple array array( 'user' => array( 'firstName' => 'Test', 'lastName' => 'Test' ), 'title' => 'Test' ) Into array( 'user.firstName' => 'Test', …
Alexander Schranz
  • 2,154
  • 2
  • 25
  • 42
0
votes
1 answer

How could I achieve sending emails in Symfony2/SwiftMailer service with the following criteria?

I'm trying to achieve a task which is killing me! I can only get an ugly message back without success! Look below my two simple classes....which they pretend through a form in my app to send emails selecting the persons in my DB according to two…
0
votes
1 answer

Get Doctrine Relationships in DQL

I have three tables: Project: ... relations: User: local: authorId foreign: id Users: class: User local: projectId foreign: userId refClass: UserProjects User: ... relations: Projects: …
dragonmantank
  • 15,243
  • 20
  • 84
  • 92
0
votes
1 answer

Notice: Undefined index: language

This question was asked so many times with different data and in different ways but I cannot see what I did wrong I am trying to query the ArticleFamily and get the entries that belong to a specific language. $qb =…
Herr Nentu'
  • 1,438
  • 3
  • 18
  • 49
0
votes
1 answer

how to group by minute with doctrine query builder

i want to do run that query with doctrine query builder select * from stats group by MINUTE(date_time) i have tried this query builder but thrown exception [Semantical Error] line 0, col 50 near 'MINUTE(s.dateT': Error: Cannot group by undefined…
Semih Sari
  • 27
  • 9
0
votes
1 answer

Doctrine2 query behavior with groupBy

I have the following custom method in the repo: $query = $qb->select('Client', 'Organization') ->from(':Client', 'Client') ->leftJoin('Client.organizations', 'Organization'); --different searh conditions-- Then I use…
Anton Igonin
  • 283
  • 2
  • 11
0
votes
1 answer

doctrine does not hydration when select custom fields

i have tried select fields with doctrine query buidler. $queryBuilder = $entityManager->createQueryBuilder(); $queryBuilder->select('au.id, au.firstName') ->from('Api\V1\Entity\AgencyUser', 'au') ->orderBy('au.firstName',…
Semih Sari
  • 27
  • 9
0
votes
1 answer

how to implement join to more than one table on same column in doctrine

My scenario is like this. item_master table item_id (primary key) | item_name -------------------------------------- 1 | Keyboard -------------------------------------- 2 | …