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

How to write exists subquery DQL for many to many association

Given the entities below, would someone please help me understand how to write the DQL equivalent of the following SQL? I can't seem to find a good example of a DQL subquery that translates to a select on a pivot table. Thank you! select * from…
Tim
  • 285
  • 1
  • 2
  • 12
0
votes
1 answer

Get OneToMany 'Child' to return object of 'Parent' if relationship is present

Using the doctrine docs example below, I would like to be able to return the all features when querying for a product. So effectively selecting all products where feature.product_id = product.id But would like to do this the doctrine object oriented…
A Star
  • 605
  • 9
  • 18
0
votes
1 answer

Customize DQL query

Hello I has the DQL query: 'SELECT t FROM VputiTripBundle:Trip t WHERE IDENTITY(t.profile) != :profile AND (t.startCity = :param0 OR t.targetCity = :param0) AND (t.startCity = :param1 OR t.targetCity = :param1) AND ... I ant to make it like…
nowiko
  • 2,507
  • 6
  • 38
  • 82
0
votes
1 answer

How to get paises from relationship

I've FabricanteDistribuidor.php entity with this code: class FabricanteDistribuidor { /** * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Pais", mappedBy="fabricanteDistribuidor", cascade={"persist"}) */ private $paises; …
ReynierPM
  • 17,594
  • 53
  • 193
  • 363
0
votes
1 answer

whats wrong with this doctrine query?

I have the following doctrine dql query, I cant see it being much different from manual but yet I get the following error: Fatal error: Uncaught exception 'Doctrine\ORM\Query\QueryException' with message 'SELECT s FROM \SessionStorage s WHERE id=…
Tschallacka
  • 27,901
  • 14
  • 88
  • 133
0
votes
0 answers

Query result Result ignored

I have a function where i do theses 2 requests : $in = $this->em->getRepository("QueensBundle:CaisseMvtArticle") ->findOneBy(array('ville_id'=>$lieu,'nature'=>'out','scoope'=>'central')); $out =…
ben muriel
  • 51
  • 1
  • 2
0
votes
0 answers

Doctrine, composite key with constant enty property?

I have to deal with a model which may contain a mistake. A Tag system which have to deal with many type of objects. Let's have an example of desired use. Tags entity is a Tag (id, name), Question entity deal with an object which have to use Tag…
0
votes
0 answers

Doctrine MaxResults and Subentities

I have a query look like this: $limit = 3; $qb = $this->createQueryBuilder('media') ->leftJoin('media.file', 'file') ->leftJoin('file.meta', 'fileMeta') ->addSelect('file') …
Alexander Schranz
  • 2,154
  • 2
  • 25
  • 42
0
votes
1 answer

Is it safe to provide variable to Doctirne Expr static methods (e.g. expr()->eq('p.var', $var))?

Is it safe to provide variables to Doctirne Expr static methods? And if it is mandatory to set them as parameters is there an easier way to do so e.g. in the $or->add() method? So can it be like: $or = $qb->expr()->orx(); if (!empty($sessionId)) { …
Grigor Yosifov
  • 1,424
  • 1
  • 10
  • 13
0
votes
1 answer

Many to Many simple Query

Can't create simple query for DB. My Entity Givetask:
0
votes
1 answer

Doctrine2 QB Sementical error on OneToMany join

I am trying to create a query using the Doctrine2 QueryBuilder. $qb = $this->getObjectManager()->createQueryBuilder(); $qb->select( array('n', 't', 'c') ) ->from('Application\Entity\Notification', 'n') …
0
votes
2 answers

SQLbuilder LIKE parameters with %

I'm trying to search in my database with LIKE now builder is working great except 1 thing: I would like to have a % in front and back of every parameter, but the way the builder works, it places a ' in front and back of every param when it is…
Kiwi
  • 2,713
  • 7
  • 44
  • 82
0
votes
2 answers

How to order by the value of a specific one to many field using Doctrine 2

I have an User, a Question and an Answer entity. Each User has n Answers. Each Answer has an unique aid. a question field holding the id of the Question answered. the actual answer string given by the user, called answer. Each Question has a…
Christian
  • 1,663
  • 19
  • 33
0
votes
1 answer

Doctrine 2.0 Query Builder Add Methods Overwrite Each Other

I thought the purpose of the query builder object was to help dynamically build queries. However, any time I try to use the query builder in this kind of a context, the helper methods overwrite one another. For example: $object_identifiers_I_need…
Michael.Lumley
  • 2,345
  • 2
  • 31
  • 53
0
votes
2 answers

sylius how to get products by taxonomy?

I have an example tree. | Brands |-- SuperTees |-- Stickypicky |-- Mugland |-- Bookmania I can get all product by subcategories in Brands, but I can't get all products by Brands. Please, help create query
John Smith
  • 43
  • 1
  • 6