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 2 Model One-to-Many Many-to-One Queries

I have such doctrine entities:
MarJano
  • 1,257
  • 2
  • 18
  • 39
0
votes
2 answers

How to set literal string values in Doctrine Update queries?

For doctrine 1.2, I find plenty of examples like these: $q = Doctrine_Query::create() ->update('mytable') ->set('amount', 'amount+200') ->whereIn ('id', $ids); What I want to do however is a different set: ->set('name', 'foo bar') This however,…
Frank N
  • 9,625
  • 4
  • 80
  • 110
0
votes
0 answers

Doctrine how to create a query builder with an operation of two subqueries

I am trying to create a query builder with doctrine with an query expression like the following: WHERE a < ((VALUE FROM SUBQUERY 1) / (VALUE FROM SUBQUERY 2)) I've been able to accomplish a < (VALUE FROM SUBUQERY 1) but as soon I add the second sub…
David Rojo
  • 2,337
  • 1
  • 22
  • 44
0
votes
0 answers

Unwanted characters in Doctrine cache

We are using Redis for as the caching driver for Doctrine in Symfony4.4. We are using the Doctrine's metadata_cache_driver, query_cache_driver, result_cache_driver which saves the cache data into Redis. But we now face an issue with the keys created…
Nandakumar V
  • 4,317
  • 4
  • 27
  • 47
0
votes
1 answer

Same Doctrine ORM listener for multiple entitites

So I will be quick. Let's say you have a postPersist event. Can you make the same listener class respond to two different entities if they extend same interface?
vukojevicf
  • 609
  • 1
  • 4
  • 22
0
votes
2 answers

Find entity with relation collection all match value

In my Symfony project, I have an "ExerciceComptable" and a "DocumentAttendu" entities. There is a relation in ExerciceComptable that reference DocumentAttendu (OneToMany). In DocumentAttendu, I have a property named "recu" which is a boolean. I need…
Pepito
  • 1
  • 1
0
votes
1 answer

Empty array from query native builder symfony6

I'm new on symfony 6.1 and i would like to understand what wrong with my custom sql request. I try many things but with no success can you help me ? This is my Accueil Controller where i want to get back the sql result from my repository…
0
votes
3 answers

Need help for performing join Query with QueryBuilder

I got a working SQL query : select p.name, p.id from acv_project p join acv_product prod on prod.project_id = p.id where prod.weight <> 0 and p.green_user_id = 18 If i pass it into a ` $stmt = $em->getConnection()->prepare($rawSql); …
0
votes
1 answer

get categories titles and elements of only that categorie - symfony

I want to show in an indexSuccess.php categories titles and the elements of that categories. These are my two tables: SgpsCategories: columns: description: { type: string(255), notnull: true } SgpsCertificats: actAs: { Timestampable: ~ } …
Eva Dias
  • 1,709
  • 9
  • 36
  • 67
0
votes
0 answers

How to query for an entity that contains an asscociated entity in ArrayCollection field (many-to-many) in Doctrine?

Setup & Problem There are two entities in my Symfony project (Entries and Persons) that are associated by a many-to-many relationship. An Entry (extended in Interview and LinkedEntry classes) can have one or more authors (ArrayCollection with Person…
0
votes
2 answers

Doctrine Query Builder with joins resulting in: "Unknown column id in 'on clause'"

Summary I'm trying to use Doctrine's Query Builder to make a SELECT that includes a number of joins. This works fine when all the joins are done through entity relationships, but when I introduce a join not through a relationship (campaign_instance…
amacrobert
  • 2,707
  • 2
  • 28
  • 37
0
votes
1 answer

Doctrine Query Error - Column not found: 1054 Unknown column 'u2_.price_type_id' in 'on clause'

I have two tables user and price_types with many to many relations that create the third table user_price_types. I want to find all price_types for a specific user so I created this Doctrine query. /** * Gets User's PriceTypes Query * * @param…
0
votes
0 answers

Doctrine 2 : Build dynamic query iterating on an array of parameters (AND conditions)

I'm trying to figure out how to correctly iterate on an array in a symfony 5 repository custom query. I explain myself. App user may check several values on a page. I want to display objects that matches all (but not necessarily only) the checked…
ovb
  • 1
  • 1
0
votes
1 answer

Doctrine Query Builder / DQL - How to write query with WHERE column = BINARY 'text'

How would I write a query such as: SELECT id FROM Records WHERE name = BINARY 'My Record'; Using Doctrine Query Builder? 'My Record' could be any arbitrary name to query for. The following does not work... Honestly, I didn't expect this to work but…
cheryllium
  • 430
  • 4
  • 15
0
votes
1 answer

Error during execution of a Doctrine DQL query converted from SQL

I have a problem rewriting an SQL query that works correctly with MySql in Doctrine Query Language (DQL). I have two tables with the following structures: -- -- Structure de la table `ame` -- CREATE TABLE `ame` ( `id` int NOT NULL, `profile_id`…