DDC-999: DQL always needs a FROM clause, should be changed #1246

Closed
opened 2026-01-22 13:07:04 +01:00 by admin · 1 comment
Owner

Originally created by @doctrinebot on GitHub (Jan 23, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user felicitus:

Sometimes a developer needs to issue a query without a FROM clause. This especially occurs using the QueryBuilder, when you may or may not have a table to select from, but call a stored procedure always.

Example:

$query = $em>createQuery('SELECT (1<ins>1)');

The above query fails because the lexer expects T_FROM. If you replace (11) with a stored procedure, this example makes more sense.

One might argue about that you should use DBAL directly, but I disagree, because it always can happen that you end up in a situation like this:

$qb = $em->createQueryBuilder();

$qb->select("SOMEFANCYPROCEDURE()");

if ($condition) {
  $qb = $qb->from("additionalTable t");
}
Originally created by @doctrinebot on GitHub (Jan 23, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user felicitus: Sometimes a developer needs to issue a query without a FROM clause. This especially occurs using the QueryBuilder, when you may or may not have a table to select from, but call a stored procedure always. Example: ``` $query = $em>createQuery('SELECT (1<ins>1)'); ``` The above query fails because the lexer expects T_FROM. If you replace (1</ins>1) with a stored procedure, this example makes more sense. One might argue about that you should use DBAL directly, but I disagree, because it always can happen that you end up in a situation like this: ``` $qb = $em->createQueryBuilder(); $qb->select("SOMEFANCYPROCEDURE()"); if ($condition) { $qb = $qb->from("additionalTable t"); } ```
admin added the New Feature label 2026-01-22 13:07:04 +01:00
admin closed this issue 2026-01-22 13:07:05 +01:00
Author
Owner

@beberlei commented on GitHub (Dec 7, 2015):

This is not a supported use-case for DQL.

@beberlei commented on GitHub (Dec 7, 2015): This is not a supported use-case for DQL.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1246