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
1 answer

Doctrine ORDER BY column but DISTINCT on another column

Can't seem to wrap my head round a Doctrine query which I am trying to execute for a monitoring system I am working on. My underlying DB is SQLite. My table is fairly simple: CREATE TABLE disk_space_usage ( id INTEGER PRIMARY KEY AUTOINCREMENT…
tip2tail
  • 463
  • 1
  • 6
  • 23
1
vote
1 answer

Doctrine DQL query to Mysql query syntax error

I am having a hard time finding out why this Doctrine dql query is not working in my symfony application. Mysql query is this: SELECT (COUNT(CASE WHEN c_email IS NOT NULL THEN 1 END) * 100.00) / COUNT(c_number) AS percentage FROM …
user12438439
1
vote
0 answers

Handling Bitmask Type in Doctrine

I have a bitmask type which stores various flags. I am having problem in executing the following query using doctrine. SELECT id, name, flags FROM stores WHERE flags & 4 = 4; I have tried the following code but I get the error saying [Syntax Error]…
1
vote
1 answer

Doctrine query builder parenthesis bad place

I have a query that receive some array parameters without any ideas how rows there is. It must return contents with all filters (AND clause), and one or more categories (OR clause). I can't get results I'd like because parentheses are not a the good…
L01C
  • 578
  • 1
  • 8
  • 25
1
vote
1 answer

Query builder "addSelect" affects "addOrderBy"

I have Symfony 4 width Doctrine, two entities/tables with relation Fixture (one) - Picture (many). Both tables has column with name "order". I am loading (eagerly) all fixtures and its pictures. I am trying to sort query result only by root entity.…
1
vote
1 answer

function Doctrine "not exists" doesn't work

I try to select a user that doesn't exist in my action table.
1
vote
0 answers

How to write/extend custom DQL Function for Cast(X $comparisonOperator Y) in Doctrine? (Goal: Show related Objects)

To show related Articles on a website, I need the Cast() function. My Query looks like: SELECT *, (CAST(a.uploader = ?1 AS UNSIGNED) + CAST(a.param2 = ?2 AS UNSIGNED) ... ) AS matches_count FROM articles AS a ORDER BY…
emovere
  • 152
  • 1
  • 13
1
vote
1 answer

Symfony authenticator: In controllers, Doctrine returns user item with empty string field, although a value is set

My database schema consists mainly of the following entities: user and auth_token. Each user can have multiple auth_token's. The problem: when selecting the currently authenticated user in a controller, the string field saltedPasswordHash is empty…
cnmicha
  • 164
  • 1
  • 3
  • 12
1
vote
1 answer

How to update table using Doctrine2 ORM and make it automatically convert datatypes?

The question is in the title. I have a custom IP-Address class, that uses INET_NTOA & INET_ATON functions and extends Doctrine\DBAL\Types\Type. What i've tried 1 $qb->update(static::class, 't'); $qb->set('t.field',…
1
vote
1 answer

doctrine querybuilder syntax error expected =, <, <=, <>, >, >=, !=, got end of string

Having following error: "[Syntax Error] line 0, col -1: Error: Expected =, <, <=, <>, >, >=, !=, got end of string." building this query with doctrine querybuiler : SELECT * FROM area WHERE ST_Contains(polygon, ST_GeomFromText('POINT(13.405584…
jj-aa
  • 1,019
  • 5
  • 19
  • 39
1
vote
1 answer

Symfony OneToOne Doctrine like in QueryBuilder

like in symfony's query builder doesn't work and show me error! this is my query: $apiToken = $this->createQueryBuilder('ud') ->select('ud.apiToken') ->where('ud.user LIKE :userPhone') …
sina
  • 111
  • 1
  • 9
1
vote
1 answer

PHP Symfony DQL - Too few parameters: the query defines 1 parameters but you only bound 0

i am trying to put together a SELECT in symfony repository project but for some reason getting error message in the subject. Been working on it for a few days but cannot find a solution with different variations of the code. This is the code $qb3 =…
Sky21.86
  • 627
  • 2
  • 9
  • 26
1
vote
1 answer

doctrine composite key and one to many

I use Symfony 2.8. I have two table and in both the primary key is composed by 3 columns: id, tipo_corso, comune 02, it, devi 01, en, capi 09, es, file Obviously the two table have other different columns. I can't change the primary key…
lausent
  • 325
  • 4
  • 13
1
vote
1 answer

In Doctrine and mySql, how to query records that do not have dates

In Doctrine QueryBuilder, I want to find all records where a date field does not have a real date. I have found, though, that the date '0000-00-00' is NULL, and it's also NOT NULL. In other words, $qb->select('t') ->from(myTable, 't') …
jcropp
  • 1,236
  • 2
  • 10
  • 29
1
vote
2 answers

Symfony2 Doctrine query builder use date function

how to use datetime functions in doctrine query builder,the below sql query need convert doctrine query(DQL). SELECT SEC_TO_TIME((SUM(TIMESTAMPDIFF(MINUTE, StartTime, EndTime)) + COUNT(*)) * 60) as hours FROM table_name The below one i have tried…
Robert
  • 3,373
  • 1
  • 18
  • 34