return DI::getDefault()->getModelsManager()->createBuilder()
->from(array('a'=>'Ativos'))
->innerJoin("Autoriza","a.autoriza = t.id","t")
->columns(array("alt_alt" => "a.altera",
"a.dia",
"t.*",
"filtro" => "if(t.data_aprovar is null or t.data_aprovar = '0000-00-00', a.dia, t.data_aprovar)"
))
->where("t.data_aprovado = '0000-00-00'")
->andWhere("a.usuario $permissao")
->andWhere("t.inativo IS NULL")
->having("filtro <= now()")
->orderBy(array("t.retorna_erro DESC", "filtro ASC"))
->getQuery()->execute();
Return "Syntax error, unexpected token HAVING" I already try to remove alias and check all the tables and fields, but Phalcon doesn't work with if statement in Mysql.
Does anyone knows how to find a solution here??