How can I use > and < operation in zf2 doctrine custom repository

时间:2015-06-26 09:44:52

标签: zend-framework2

I want to run

$qry = $qb2->where("n2.userFk!=0 AND n2.id >1 <20") 

in doctrine repository but it is not working. It is giving error for > and < operators.

1 个答案:

答案 0 :(得分:0)

Use expressions:

$expr = $qb2->expr();
$qry = $qb2->andWhere(
    $expr->neq('n2.userFK', 0)
    $expr->andX(
        $expr->gt('n2.id', 1),
        $expr->lt('n2.id', 20)
    )
);