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

Why will Doctrine ORM will not create SQL query for my 1-to-many model?

I know this has to have an easy answer, but I cannot figure it out. After tears, I am hoping someone here can help. Here is my YML model: Identity: columns: id: type: integer(10) primary: true autoincrement:…
So Over It
  • 3,668
  • 3
  • 35
  • 46
1
vote
1 answer

Doctrine Set Multiple Criteria One At A Time Instead Of All At Once

I'm using the KendoUI Framework GRID which returns back JSON of the users current filter settings. Its result looks something like this for the…
Joseph Astrahan
  • 8,659
  • 12
  • 83
  • 154
1
vote
2 answers

Doctrine join WITH vs WHERE

I'm joining multiple tables and I found two solution. I can't ready figure out what is the diference. Can anyone tell me? Solution 1: $query = $entityManager->createQuery(" SELECT m FROM Model m JOIN m.battery b JOIN m.camera c …
Robin Dijkhof
  • 18,665
  • 11
  • 65
  • 116
1
vote
1 answer

DQL subquery - is already defined

I'm trying to reuse the definition name "comments" - table Comments (AppBundle:Comments entity) in the 5th DQL subquery, but I get the error: "Error: 'comments' is already defined." Here is the DQL query: SELECT employer.name AS employer_name,…
eXtreme
  • 244
  • 3
  • 18
1
vote
1 answer

Doctrine 2 | Criteria vs DQL | Performance & Usability

I was wondering what is the best practice for fetching collections by complex queries in Doctrine 2. I have been using the Cirteria matching functionality, but I want to know if it is usable for large scale databases. $expr =…
1
vote
1 answer

Symfony2 index of an object sorted by DQL

Hi I've done a simple query for a ranking mechanism with the query builder. $result = $qb ->select('u') ->where('u.status = 1') ->from('PGMainBundle:User', 'u') ->groupBy('u.id') …
Deska
  • 87
  • 10
1
vote
1 answer

Doctrine QueryBuilder getResult not returning nested array

I have a join query in my "Item" entity repository class: public function findByParentItem(parentItemCodes, excludedModules) { $qb = $this->getEntityManager()->createQueryBuilder(); $qb->select('i', 'p') ->from('Bundle:ItemParent',…
juhah
  • 11
  • 5
1
vote
0 answers

NativeQuery to queryBuilder impossible but i need querybuilder for my form entity type

I have a sql query too complex to translate in QueryBuilder. It works by nativequery. The problem is that my entity type asks me a QueryBuilder not a query. Do you have a solution? This is my query : SELECT v.* FROM vat_rates v INNER JOIN ( …
1
vote
1 answer

Multiple WHERE conditions on the same table columns

I am trying to get parts which have certain attributes. Each part has many attributes, and each attribute has an attributeheader. So there's three tables that I need to use. SELECT * FROM Part p LEFT JOIN p.attributes pa JOIN pa.attributeheader…
Jonnerz
  • 1,111
  • 2
  • 11
  • 16
1
vote
0 answers

doctrine orm:run-dql gives semantical error class is not defined

I am new to Doctrine and trying to run DQL statements with the Doctrine CLI tool for convenience in debugging. My configuration appears to be set up correctly in cli-config.php. I can run things like vendor/bin/doctrine orm:info and generate setters…
David
  • 815
  • 8
  • 18
1
vote
0 answers

Doctrine Query Adding Random Order By to End of Query From Subquery

I've been trying for hours now but everytime i create a DQL query with a subquery, it seems to add an ORDER BY to the end that should be apart of the subquery even though i haven't explicitly asked for an ORDER BY. Here's my…
Richard Skinner
  • 738
  • 3
  • 10
  • 26
1
vote
1 answer

Query Builder inside Symfony2 Entity Form

Right now I have a problem with the query builder function of the entity form type inside Symfony. Other questions on this board did not help me to find a solution: See e.g.: 8456298 or 13846970 or enter link description here Here's the situation:…
1
vote
1 answer

Doctrine2: Use date functions in QueryBuilder

I want to know how to use date functions like WEEK or MONTH in query builder. I'm using Zend not Symfony. When I try my current code with WEEK I get this error: Error: Expected known function, got 'WEEK' This is my current code:
raygo
  • 1,348
  • 5
  • 18
  • 40
1
vote
1 answer

Addition and Subtraction with Query Builder Doctrine ORM 2

I have a transaction table with a list of transactions (deposits) made by my users. ID | user_id | credit | debit | status 1 | 1 |5 |1 2 | 1 |12 |1 3 | 1 |8 |1 To figure out the current balance of each user, I need to take the sum of all the…
HappyCoder
  • 5,985
  • 6
  • 42
  • 73
1
vote
3 answers

format an array result query from doctrine to a simple array

I have this controller with a doctrine query: $em=$this->getDoctrine()->getManager(); $queryIndex = $em->createQuery( 'SELECT g.index FROM MySpaceMyBundle:Graphique g'); $result =…
french_dev
  • 2,117
  • 10
  • 44
  • 85