带变量的 DoctrineSelect

DoctrineSelect with Variable

我正在尝试这样的教义:

SELECT 
    @myprice := cp.price,
    @compPrice1 := (SELECT cpt1.price FROM competitor_product AS cpt1 
                    WHERE cpt1.product_id = cp.product) as compPrice1 
    @compPrice1 / @myprice  AS price_diff
FROM
    customer_product AS cp 
WHERE 
    customer_id = 1;

在那之前我的代码:

[我的代码在那之前]

如何设置用于计算列的变量?

我一直在寻找,但一无所获

我认为 Doctrine 查询构建器不可能做到这一点。我建议使用 Doctrine Native Query 或原始 SQL 查询。