0
Hi, I’m new to PHP OO and in the Doctrine. I would like to return the value of a function within another function. Is it possible? Both are within the same class.
Function that will receive the result:
public function salvar(Request $request, EM $em)
{
$FinContaspagar = new FinContaspagar(
$_SESSION["grupo"],
$_SESSION["estabelecimento"],
$request->get('terceiro'),
/****************RESULTADO DA FUNÇÃO AQUI**********/,
$request->get('dtemissao'),
$request->get("dtvencimento")
);
$em->persist($FinContaspagar);
$em->flush();
return redirect('contas')->with('success_message', 'Cadastrado com sucesso');
}
Function that generates the value:
public function insereCodigo(em $em){
$query = $em->createQuery('SELECT COALESCE(MAX(u.codigo+1),1) as Codigo
FROM ModuloFinanceiro\Entities\FinContaspagar u
WHERE u.grupo = :sessionGrupo
AND u.estabelecimento = :sessionEstabelecimento');
$query->setParameter('sessionGrupo',$_SESSION["grupo"])
->setParameter('sessionEstabelecimento',$_SESSION["estabelecimento"]);
$codigo = $query->getResult();
return $codigo[0]["Codigo"];
}
If it is not possible, or is not recommended to do so, how can I proceed?
Thanks @Evandro! The first solution worked! I was doing exactly the same as the second way, really not right. Thanks!
– Felipe Nunes