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

Is there a way to use a Doctrine reserved word in a DQL statement?

Is there a way to use a Doctrine reserved word in a DQL statement? I would like to use an Entity class called "Member" but I cannot use it neither with QueryBuilder nor Query, aliases, etc. Examples : $qb =…
b126
  • 544
  • 4
  • 11
1
vote
2 answers

Want to return data in Json format by getting from database Object. Php Symfony

I am getting data from database model and want to return in json format, but it returns empty array, but when i use dump for variable that contains objects data then it return the actual data. Here is the code for getting data from object $user =…
Timothy
  • 69
  • 7
1
vote
1 answer

Using Array Entity in Doctrine Query Builder

How are you? I created an array entity. /** * @Groups({"event_rating_question", "portal"}) * * @ORM\Column(type="json", nullable=true) */ private ?array $eventTypeIds = []; In the repository, I want to get the results…
Maksim
  • 21
  • 4
1
vote
1 answer

Doctrine ORM: Excluding Records Based on Values of Nested Relationships

Quick Overview Hey guys! I'm working on an app that has the ability for an Order to contain multiple OrderStatus which then have a relationship with the Status entity themselves. Here's a sort of simplified ERD diagram: The Question: What I want to…
Ervin Šabić
  • 115
  • 3
  • 14
1
vote
1 answer

DQL joined relationship doesn't populate

I have 2 entities: User and Metadata. They have a bi-directional one-to-many relationship (a user can have many metadata records). In a context decorator I'm using for flagception, I query the user and some of the user's relationships that may be…
amacrobert
  • 2,707
  • 2
  • 28
  • 37
1
vote
2 answers

How is it possible to map column names from a Doctrine sql query?

I created a query with query builder like this: $qb = $em->createQueryBuilder(); $qb->select(['u.id', 'u.name']) ->from(User::class, 'u') ->where('u.active = 1') ; $sql = $qb->getQuery()->getSql(); The result looks like this: SELECT…
Iter Ator
  • 8,226
  • 20
  • 73
  • 164
1
vote
1 answer

Doctrine Symfony getting multiple object columns and multiple columns from a relationship object

friends! I want to get the selected columns of my object from the database, as well as the selected columns of the related objects. But when I execute my query, I get the data but the related objects are not converted into separate arrays but are…
1
vote
2 answers

DQL vs SQL, why i don't have the same result?

I started to create DQL request, but I have a little problem and I don't know why. SELECT count(*) FROM bw_ach bw where type_demande = 'MES' and soustype_demande in ('MES avec intervention', 'MES dégradée') and…
1
vote
2 answers

Need Doctrine Many to Many QueryBuilder Query to Return NOT In Common Rows

I have two tables 1) Prices and 2) Users Owner is a column in the Prices table. Both tables have a many to many relationship between price.users and users.price. The query below returns all Prices shared by owner1 and user1. Question: How do I fix…
1
vote
3 answers

Doctrine : how to make a nested query with the query builder?

Good evening I'm still a junior in SQL queries and the Doctrine query builder. My problem is simple, so simple that I've been searching for a few hours. I'm in a symfony 4.4 LTS project. I have a table that represents the orders placed on an…
1
vote
3 answers

symfony querybuilder for search by relation in collection

I have Entity Application with relation to Applicant /** * @ORM\ManyToOne(targetEntity=Applicant::class, inversedBy="applications") * @ORM\JoinColumn(nullable=false) */ private $applicant; now I try create QueryBuilder for…
mardon
  • 1,065
  • 1
  • 11
  • 29
1
vote
0 answers

Symfony Doctrine - use CTE with query builder

I'm failing to use a Common Table Expression with symfony. I have a class App\Entity\User and a class App\Entity\Account I want to collect account available to a list of user and all the accounts not associated to any user. I would want to pass this…
1
vote
2 answers

Persisting selected entities in mapped relationships in Doctrine 2

I am trying to map a relationship between 2 MySQL tables in Doctrine 2. My owning entity is 'Campaign', it joins to 'Channel'. When a campaign record is saved, it must contain a channel id. When a campaign is retrieved I would like to use this id to…
Richard
  • 422
  • 7
  • 17
1
vote
1 answer

Syntax Error line 0, col 60: Error: Expected end of string, got 'ON' - Symfony 4/Doctrine2

I have problem with query builder using Doctrine 2 in Symfony 4.4 and Omines/Datatables Bundle. I have two entities, User and Log, which look like this:
1
vote
0 answers

Hydrating DATETIME fields in a random Doctrine DQL query

I have a DQL query which contains a lot of DATETIME fields from multiple entities and uses aggregation functions as well. The fields of entity classes themselves have the proper annotations like so: @Column(name="transaction_date", type="datetime",…
ax1mx2
  • 654
  • 1
  • 11
  • 23