Hello! Faced such a problem, the project uses doctrine 2, there is a query in the database prepared by Doctrine QueryBuilder. To it you need to add 1 row from another table. itself suggests to use UNION, but QueryBuilder does not support it. You can rewrite everything using NativeBuilder, but then the application works with the QueryBuilder object and will have to redo much. Maybe someone knows how to do with a little blood and add a line, maybe there is a way to feed a QueryBuilder sql query? or something else?
$query->select($selectFields)->from($transactionTableName, 't')->leftJoin('t', 'user', 'u', 'u.id = t.executorId')->join('t', $operationTableName, 'o', 'o.id = t.operationTypeId AND o.isBase = 1'); if ($relationAdapter instanceof \Payment\Service\Adapter\Credit) { $query->leftJoin('t', $relationTableName, 'senderRel', 'senderRel.id = t.senderRelationId')->join('senderRel', 'creditRequest', 'credit', 'credit.id = senderRel.creditId')->join('credit', 'procedureLot', 'lot', 'lot.id = credit.lot_id')->join('lot', 'procedures', 'p', 'p.id = lot.procedureId'); } else { $query->leftJoin('t', 'procedureLot', 'l', 'l.id = t.lotId')->leftJoin('l', 'procedures', 'p', 'p.id = l.procedureId'); } $query->where('t.recipientRelationId = :relation')->orWhere('t.senderRelationId = :relation')->orderBy('t.dateTime', 'DESC')->groupBy('t.id')->setParameter('relation', $relationAdapter->getRelation()->getId()); $query->addOrderBy('t.id', 'DESC');