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
2
votes
0 answers

How to use query function LIKE and CONCAT in the same time

User will send a message for example user1 = "Show football score today plz" user2 = "Show basketball score yesterday lol" the key is "score" I want to query that word form all sentence by use this two function function like() and function…
B. Godoak
  • 295
  • 6
  • 20
2
votes
1 answer

Select fields from many to many relationship between 3 tables in Doctrine and ZF2 with query builder

I have User Entity: class User{ ... /** * @var Module $modules * @ORM\ManyToMany(targetEntity="Adm\Entity\Module", inversedBy="users", cascade={"persist"}) * @ORM\JoinTable( * name="user_module", * …
2
votes
1 answer

How to implement subqueries in Symfony2 with Doctrine?

I need to count the number of items returned in the subquery. If I write the subquery how DQL - all good, but if I try to build a query via QueryBuilder - I get an error. Subquery DQL: $qb3 = $this->createQueryBuilder('c') …
2
votes
2 answers

Problem with two requests on a table in one action

I have an action with two requests on an unique table. The results of the requests must be different. But, the result is the same for my two requests and it comes from my second request. // Récupération du (ou des) locataire(s) actuel(s) du…
Elorfin
  • 2,487
  • 1
  • 27
  • 50
2
votes
0 answers

Use LIMIT and OFFSET with doctrines addSelect?

I have following code: ->createQueryBuilder() ->select("c.id, c.address, c.name") ->addSelect('(SELECT o.name FROM OOHMediaBundle:Offer o WHERE p.contractor_id = c.id ORDER BY o.created_at DESC LIMIT 1 OFFSET 0) as…
przemo_li
  • 3,932
  • 4
  • 35
  • 60
2
votes
0 answers

add field on result of Dql

I'm trying to associate a field of my entity with a left join : $query = $em ->createQueryBuilder() ->select('Page, partial Template.{id,name}') ->from('WHCmsBundle:Page', 'Page') ->leftJoin('WHCmsBundle:Template', 'Template', 'WITH',…
user3646875
  • 143
  • 1
  • 9
2
votes
3 answers

Get children's posts in parents with Doctrine Extensions Tree Nested set

I'm using the nested set behaviour in Symfony2 with StofDoctrineExtension. The category and post model are well configured, and the category tree works fine. To show the posts of a category I use this query from my repository: public function…
Diego
  • 709
  • 7
  • 18
2
votes
1 answer

Doctrine query with join. Getting results

I can't get results in view from query. Here is controller method: public function indexAction() { $this->layout()->setVariable('page_title', 'Страницы'); $pages = $this->getServicePage()->getPageList($type = 1); $viewModel = new…
2
votes
1 answer

Custom operator in Doctrine DQL

Good day. Please, tell me, how is it possible to create custom operator for Doctrine DQL? I'm using Postgresql ltree extensions, which have many specific operators, such is @>, <@, ||, ~ and others. But I can't using it in my dql queries. Now, I…
Lev Semin
  • 243
  • 2
  • 10
2
votes
1 answer

Doctrine Query Builder Result: not looping correctly

I'm not sure if it's that I'm not doing correctly but this is giving me an error: I have 2 Entities: Task and TaskUser. They are connected by a onetoMany. What I want to do is this: foreach($tasks as $task){ echo $task->getTitle; echo…
raygo
  • 1,348
  • 5
  • 18
  • 40
2
votes
1 answer

Doctrine 2 Self Join Query

I'm still pretty new to Doctrine and I'm trying to retrieve a suggest list of users to follow. So basically, given an user A, I need to select all users that are followed by the users that user A follow, excluding users that user A already…
Remi M
  • 436
  • 2
  • 6
  • 16
2
votes
1 answer

Symfony 2, QueryBuilder, multiple andWhere with same parameter

I have two entities - Lawyer and Category. They are connected with Many to Many association. Assume that example lawyer has 3 categories. I want to create function to search lawyers by a array of categories, and it should return only lawyers who…
dees91
  • 1,211
  • 13
  • 21
2
votes
2 answers

How to turn this SQL query into Doctrine Query

I'm using this native SQL query on symfony (Which is a really bad practice) but I'm struggling to get it running with DQL without triggering several errors. SELECT Image.path, Image.name FROM Image LEFT JOIN ImageVoters ON Image.id =…
user3531149
  • 1,519
  • 3
  • 30
  • 48
2
votes
1 answer

LIKE on subquery in WHERE clause with Doctrine2

I'm on a symfony2 project, and I've got an issue with the following query : SELECT count(a) FROM CoreBundle:Agency a WHERE ( SELECT count(c.id) FROM CoreBundle:Agency a1, CoreBundle:Client c WHERE a1.id = c.agency AND a1.id = a.id )…
Aly
  • 458
  • 2
  • 13
2
votes
2 answers

why is this not possible in doctrine

I have to do some queries, while i was trying different ways, i found out that the next lines are not "recognized" by doctrine (it gives errors): for example, when i want to compare if some data in the db is equal to a literal, here the…
Limon
  • 1,772
  • 7
  • 32
  • 61