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

Doctrine pain while accessing members of a left join that are null

I have a Doctrine query in my model say Model_1Table.class.php that left joins with Model_2. Model_2 relates to Model_1 on a many-to-one relation. (it really is a one-to-one relation and not a many-to-one but the schema got designed so) My query…
user1020069
  • 1,540
  • 7
  • 24
  • 41
3
votes
2 answers

Transparently executing SQL functions when loading/saving a field in Doctrine 2

I'm working with Doctrine2, and have a entity containing a string property that represents a WKT geometry: class Entity { /** @Column(type="string") */ protected $wkt; } I'd like to have this field transparently saved to a GEOMETRY field in…
BenMorel
  • 34,448
  • 50
  • 182
  • 322
3
votes
1 answer

How to monitor and to log slow queries in Symfony + Doctrine

I am working on a Symfony 3.4 based project using Doctrine 2.6. Is it somehow possible to automatically monitor all Doctrine queries and log those with an execution time above some threshold? I have used blackfire.io and other tools on my dev…
Andrei Herford
  • 17,570
  • 19
  • 91
  • 225
3
votes
2 answers

Symfony Doctrine DQL cannot find createQuery in entity manager

I've been learning web development with Symfony for some time now. I was following the tutorial on Symfony's website and Doctrine tutorial, and tried to use entity manager in the Doctrine ORM to create queries but PhpStorm's autocompletion tells me…
yatsky
  • 95
  • 1
  • 10
3
votes
1 answer

Get elements from LazyLoadCollection

I have found Doctrine\Common\Collections\Criteria to be a very useful concept, if they worked for me. In a symfony controller, I am calling this code: $criteria = Criteria::create() ->where(Criteria::expr()->gt('position', 0)) …
olidem
  • 1,961
  • 2
  • 20
  • 45
3
votes
1 answer

Doctrine MongoDB ODM - Return only matched embedded document using query builder

I am having trouble in returning only the matched embedded document using MongoDB ODM query builder in PHP. Each embedded document has a MongoID generated at the time of creation. Following is my document structure of collection Project: { …
Seeker
  • 1,877
  • 4
  • 32
  • 56
3
votes
3 answers

Symfony / Doctrine Error: "Class 'FROM' is not defined." on getResult()

I'm developing my first symfony app andwhile trying to use the queryBuilder I've been struggling with an issue for a couple of hours. I'm trying to execute a SQL query and I get the following error: request.CRITICAL: Uncaught PHP Exception…
SMASHED
  • 466
  • 5
  • 9
3
votes
1 answer

Doctrine 2.5 Unexpected association fetch behavior [Symfony 3]

I have 3 entities associated this way: Don't worry, I've set associations using annotations, but I thought the following mix would be lighter/cleaner to expose my issue Post @ORM\ManyToOne(targetEntity="User", fetch="EAGER") - author User …
Stphane
  • 3,368
  • 5
  • 32
  • 47
3
votes
1 answer

How to make complicated SQL query in doctrine

I have 2 tables: users and their points. Users have fields: id name Points have fields: id start_date end_date count_of_points user_id So some users may have or not have points. Points entries limited by time interval (from start_date to…
3
votes
1 answer

Doctrine2: [Semantical Error] Cannot select entity through identification variables without choosing at least one root entity alias

This is my query with query builder, and it works perfectly, bringing all the results of user table and the modules table, which has a many to many association: public function getUser($id){ $qb = $this->getEm()->createQueryBuilder() …
3
votes
2 answers

generate unique serial numbers for shop order the doctrine way

We built a shop system with symfony2 using doctrine which has to generate unique serial order numbers. There's an Order entity which originally had a property orderNumber The Order entity is our "shopping session", so not only submitted orders are…
edditor
  • 150
  • 1
  • 10
3
votes
1 answer

symfony2 createQueryBuilder

I am trying to make a really simple sql query from repository class, just select * from Adjudicacion where cursoAcademico_id=$cursoAcademicoActual;: This is my entity: /** * Adjudicacion * * @ORM\Table(name="Adjudicacion") *…
Pedro Gonzalez
  • 180
  • 1
  • 2
  • 11
3
votes
3 answers

Doctrine2 fetch Count more optimized and faster way Or Zf2 library

I am using Doctrine2 and Zf2 , now when I need to fetch count of rows, I have got the following two ways to fetch it. But my worry is which will be more optimized and faster way, as in future the rows would be more than 50k. Any suggestions or any…
Deepanshu Goyal
  • 2,738
  • 3
  • 34
  • 61
3
votes
1 answer

Can Doctrine QueryBuilder andWhere() used without where()?

In Doctrine, when building a query with QueryBuilder, does the first whereclause have to be defined with $qb->where()or can I use $qb->andWhere() directly. For example, is this valid: $qb->select('Mystuff\Entity\User','u'); $qb->andWhere('usertype =…
Ilari Kajaste
  • 3,207
  • 2
  • 23
  • 25
3
votes
0 answers

Benefits of QueryBuilder vs Lazy Loading in Doctrine 2.0

I am creating a Zend Framework project that utilises Doctrine 2.0 When creating my own custom repository, I originally "cheated" in returning results, instead of working out the DQL (or using QueryBuilder) to obtain results, I just used the model…
1 2
3
24 25