php - ZF2 changing my expression and returning error (Postgre, Distinct) -
i have make select distinct rows column idcontrato. did with sql...
select distinct on (idcontrato) * cad_emprestimo numerobeneficio = '1135346515';
but when try same zf2:
$emprestimos = (new emprestimotable())->select(function(select $select) use($cliente) { $select->columns([new expression('distinct on (idcontrato) *')]); $select->where->equalto('numerobeneficio', $cliente->getbeneficio()->getnumero()); });
i got following error:
sqlstate[42601]: syntax error: 7 erro: erro de sintaxe em ou próximo "as" line 1: select distinct on (idcontrato) * expression1 "cad_e... ^
this 'as expression1' added zf2... don't know how remove it.
try below code
$emprestimos = (new emprestimotable())->select(function(select $select) use($cliente) { $select->columns([new expression('distinct(idcontrato) idcontrato'), '*']); $select->where->equalto('numerobeneficio', $cliente->getbeneficio()->getnumero()); });
Comments
Post a Comment