0
Hello
I’m having trouble recovering the Return from a model and using it in a loop (foreach), without the function running again several times...
How can I take Return and use it several times?
Code for illustration:
$valorModel = $this->model->funcao(); // recupera o return
foreach ($var as $var2) {
$array = array(
'colunaDb' => $var2->item,
'colunaDb' => $valorModel, // executa a função varias vezes
'colunaDb' => $var2->item
);
}
It would be good to post part of the code to help in understanding...
– Lucas Augusto
posted a code to illustrate my problem
– zyzzete
Did you return $query->result()? If you return only one element, for example, use $query->Rows->fieldName.
– Israel Zebulon