Welcome Guest, Not a member yet? Register   Sign In
(SOLVED) doubt with free_result
#1

[eluser]jozeunico[/eluser]
Can I do the $query->free_result() after the return in the function in my model ?

I mean it works if I do this:

function getAnios($id_fondo){

$sql = "SELECT ani_inicio,ani_final from uia_fondos WHERE id = $id_fondo;";

$anios = $this->db->query($sql);


return $anios->row_array();

$anios->free_result();
}

Or i need to return the object $anios to my controller and then do the $anios->free_result()?

Thanks everybody for your time.
#2

[eluser]bretticus[/eluser]
You must call free_result() before return. Set $anios->row_array(); to a variable and then call free_result() and then return that variable.

From the PHP manual...

Quote:If called from within a function, the return() statement immediately ends execution of the current function, and returns its argument as the value of the function call.
#3

[eluser]jozeunico[/eluser]
Thanks, in fact that it is what I did, (just in case jeje), and thanks because I didn't be sure about that until now, thank you again




Theme © iAndrew 2016 - Forum software by © MyBB