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

Doctrine update query with LIMIT

I would like to do an update-query with a LIMIT like that: UPDATE anytable SET anycolumn = 'anyvalue' WHERE anothercolumn='anothervalue' LIMIT 20 How is this possible with doctrine 2.1 ?
scube
  • 1,931
  • 15
  • 21
2
votes
1 answer

Doctrine one-to-many UNIDIRECTIONAL find on owning side

Problem definition So given this part of Doctrine documentation (and many other articles about bidirectional association and persistence problems), I have a one-to-many association that is unidirectional. It is between a Club and it's Staff members.…
2
votes
1 answer

Doctrine - How do you use a subquery column (in the SELECT clause and having condition)

Hello i am trying to rewrite ZF query builder into doctrine ORM. Here IS mine old Zend framework query. $dependent = new Zend_Db_Expr('if(br.billing_rate = \'dependent\',(SELECT COUNT(*) FROM childcare_billing_rule_price AS p WHERE p.id < brp.id AND…
Ambulance lada
  • 311
  • 1
  • 2
  • 14
2
votes
1 answer

avoid Doctrine DBAL query builder select statement to transform camelcase aliase names to lowercase

I'm using doctrine DBAL in custom PHP application and in my case when I use query builder select statement for example like: ->select( 'roles.id as roleId', 'roles.slug as roleSlug', 'roles.name as…
Bogdan Dubyk
  • 4,756
  • 7
  • 30
  • 67
2
votes
0 answers

sfDoctrinePager with custom query returned only one row

I've tried to combine my Doctrine_Query and sfDoctrinePager, but when I fetch the results, it's always return one row (when I run the generated query in my database it was normal) this is my code: $pelanggan = Doctrine_Query::create() …
HQM
  • 558
  • 1
  • 3
  • 15
2
votes
1 answer

Doctrine ORM : Undefined offset 2

I'm working on a request to pick up some result from the database but I have an error and I don't know how to resove it in my repository : public function findBySearchField($salary, $contract, $experience, $training) { return…
BanjoSf4
  • 149
  • 1
  • 1
  • 13
2
votes
1 answer

Reset (clear) a table in Doctrine ORM 2.5 and Symfony 3.4

Using Smyfony 3.4 and Doctrine ORM 2.5 (mySql) I am looking for a way to "reset" a table. By reset I mean I want to delete all entries of that table and reset the autoincrement for the id column. Basically I want to get the initial state when the…
user3440145
  • 793
  • 10
  • 34
2
votes
1 answer

Symfony/Doctrine - QueryException - [Semantical Error] line 0, col 48 near 'pizza-mia': Error: 'pizza' is not defined

I want to make this query in SQLite using DQL //// src/Repository/PostRepository.php public function hasPreviousPost($id,$slug): array { $em = $this->getEntityManager(); $query = $em->createQuery('SELECT p FROM App\Entity\Post p WHERE p.id…
Eleni Ioakim
  • 53
  • 1
  • 7
2
votes
1 answer

Doctrine order by compound expression

I want to replicate the following query which sorts all users by name, but those whose names start with Z come first: SELECT * FROM user ORDER BY LEFT(name, 1) != 'Z', name I have this: $qb =…
mdhuke
  • 111
  • 5
2
votes
2 answers

Doctrine query builder find by interests

today i have an interest task - realize search on DB by some groups and sort it by most relevant criteria We have 2 entities (User and Interests) on Symfony with ManyToMany relation We need create query for find users which have most similar…
2
votes
2 answers

Possible to use groupBy column as associative array index for grouped collections with Doctrine query builder?

Given a table structure like the following: Matches: | id | round | home_team | away_team | | 1 | 1 | Juventus | Milan | | 2 | 1 | Inter | Roma | | 3 | 2 | Juventus | Inter | | 4 | 2 | Roma | Milan …
Thomas Maurstad Larsson
  • 2,217
  • 2
  • 21
  • 19
2
votes
1 answer

QueryBuilder : how to compose subselect clause

I'm having trouble converting a plain SQL clause to a Doctrine query. I've added the clause in plain SQL below: $query = $doc->getEntityManager () ->createQueryBuilder () ->select ( 'r') ->from ( 'AppBundle:CFormResponse', 'r' ) ->where (…
Black
  • 5,023
  • 6
  • 63
  • 92
2
votes
0 answers

Limit Clause While Fetching Child Records in Doctrine

I have two tables Entity and Message. as each entity can have many messages so it's like parent child relation. I dont want to use doctrine custom query so I am loading entity message like $this->currentUser =…
Alinawaz
  • 21
  • 2
2
votes
0 answers

How to select specific properties of properties through DQL

I have the following Entities. First and foremost: the design derived from a legacy DB and it has been semplified here for clarity shake. What I would like to do is selecting all the widgets along with their varsSelection populated (in this very…
Bertuz
  • 2,390
  • 3
  • 25
  • 50
2
votes
0 answers

Symfony/Doctrine: I can query my database but only primary key data is being retrieved

So the DQL below works but there is a problem with the records returned. It only displays the primary key data. All other fields are empty/null. I know my code is communicating fine with my Oracle DB since if I misspelled the table name, it will…
mrjayviper
  • 2,258
  • 11
  • 46
  • 82