0

The database I work with has an offset on one of the table's key. In plain SQL this would look like:

SELECT * FROM foo f LEFT JOIN bar b ON f.id = b.id - 1

I tried to use Expr\Join::ON with QueryBuilder, but that gives me an error saying that Expected end of string, got 'ON'. Example below.

I also tried Expr\Join::WITH with QueryBuilder, but that returns nothing for that join. In other words, $element->getBar() returns null. Example below.

I cannot modify the database structure or data. I have to work with it as it is.

Example of QueryBuilder usage:

return $this
  ->createQueryBuilder('f')
  ->select('f, b')
  ->leftJoin('f.bar', 'b', Expr\Join::ON, 'f.id = b.id - 1');
  // ->leftJoin('f.bar', 'b', Expr\Join::WITH, 'f.id = b.id - 1');
TheFrost
  • 1,265
  • 2
  • 15
  • 29

0 Answers0