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

Change entity name in creatquerybuilder according to specific condition in symfony?

For example: - Query 1 - Select name from admin, and Query 2 - Select name from user Both are identical tables with different names, so I am doing like this but it's not working: $entityName = User::class; $query = $this->_em->createQueryBuilder() …
Ak Dutta
  • 3
  • 3
0
votes
1 answer

Doctrine - relation of three tables

I have trouble with writing Doctrine Query Builder. I have a Posts table which is related to the AccountToken table like: class Posts /** * @ORM\ManyToOne(targetEntity="App\Entity\AccountToken") * @ORM\JoinColumn(name="account_token_id",…
pohofo
  • 89
  • 2
  • 8
0
votes
1 answer

How to join column and target entity manually in manytoone relation?

I have two fields : account_type_id and account_id. How can i manually map doctrine TargetEntity to join Company Entity if accountTypeId = 1 OR join User Entity if account_type_id = 2 ?
Titeufggg
  • 21
  • 3
0
votes
0 answers

Bug in Sonata Admin? Extra rows are added in list when selecting joined entities

Could this be a bug in Sonata Admin bundle? Let's say I have an entity A that can have multiple B's. To see this in my database, I would write something like select * from a inner join b on b.a_id = a.id; This would give me a result set with every…
henrik242
  • 366
  • 4
  • 11
0
votes
1 answer

Undefined method 'createQueryBuilder'

I'm getting error for "$qb = $this->getDoctrine()->getManager()->createQueryBuilder();" this line in my project file . Can someone help me enter image description here
0
votes
1 answer

Syntax Error: line 0, col 72: Error: Expected end of string, got 'b6f037'

I'm doing a query and I get a strange error that I don't understand how it works or why it happens. I'm new to symfony so bare with me. My Goal is: To Select for a table but I want to exclude the current users data. /** * @param int $getIndex …
0
votes
1 answer

My doctrine query returns error with distrinct

I am trying to return my visits but I need a distinct and not a count. I tried these repository methods but only count works. Working: public function numberOfVisitsBetweenDates($dateMin, $dateMax) { $builder =…
0
votes
2 answers

Doctrine query builder with in expression

I try to get all users who has a mail in three different properties with in expression $qb = $this->createQueryBuilder('i'); $qb->where(':email in (i.firstMail,i.secondtMail,i.thirdtMail)'); I got this error in getResult [Syntax Error] line 0,…
user3427807
  • 31
  • 1
  • 3
0
votes
1 answer

Using multiple filters for the same entity field in Doctrine (Symfony 4.4)

I'm trying to build a query builder where the user can select multiple filters in Twig and I want them all to be applied on the same entity class. I already tryied to use or and orwhere in the query. Am I making a mistake? Or is there maybe a way to…
user15117959
0
votes
1 answer

Crafting a Doctrine subquery that hinges on a ManyToMany Relationship using the QueryBuilder

Trying to shake some rust off, and understand how I'd do this with the query builder! I've tried a few approaches, and was met with all kinds of cryptic errors. Haven't visited this way of doing things for awhile, and appreciate the help! I have a…
Saeven
  • 2,280
  • 1
  • 20
  • 33
0
votes
1 answer

How to use functions in Doctrine query builder

In my symfony project, I search data in the database with Doctrine QueryBuilder : public function search($name) { return $this->createQueryBuilder('Town') ->andWhere('Town.name LIKE :name') ->setParameter('name', '%' . $name .…
Toms River
  • 196
  • 1
  • 4
  • 13
0
votes
1 answer

Symfony 5.2 : Problems with Argument passed in Dynamically Modifification Form Using Form Events

I try to apply documentation https://symfony.com/doc/current/form/dynamic_form_modification.html but i have some troubles when I receive the result of the first select categoryLevel1Id to collect options in the second select categoryLevel2Id. I'm…
Steph TwX
  • 59
  • 2
  • 10
0
votes
0 answers

Symfony Distinct On date_trunc

Hi i have a problem i want use symfony doctrine for my request in native SQL it works but i want make it in doctrine. I use symfony4 I have create custom DQL date_trunc and register What i want to do is that : DISTINCT ON (date,ipp.link)…
0
votes
1 answer

How to iterate over Doctrine collection mixed with Proxies and Objects

I'm using Doctrine in a project where I need data from multiple tables. In order to escape from N + 1 problem I'm fetching all the data, that I need before it go to the view. As I saw in the documentation the way to do this is to make a join with…
zhelyazko777
  • 17
  • 1
  • 5
0
votes
1 answer

Problems with Doctrine QueryBuilder

This is my first project with Symfony / Doctrine I have this entity called Nuclei class Nuclei { /** * @var int * * @ORM\Id * @ORM\Column(name="id", type="integer", nullable=false) * @ORM\GeneratedValue(strategy="NONE") …
Augusto Murri
  • 183
  • 1
  • 19