I have a class with a function that returns an array
function buscarPorComplejo($idComplejo){
$sql = "SELECT * FROM XXX where id_complejo = '$idComplejo' ";
$rs = mysql_query($sql) or die("Error en la Busqueda -cabanas-");
$reg = 0;
while($row = mysql_fetch_array($rs)){
$vec["$reg"]["id"] = $row["id"];
$vec["$reg"]["descripcion"] = $row["descripcion"];
$vec["$reg"]["cantidadHuespedes"] = $row["cantidad_huespedes"];
$vec["$reg"]["idComplejo"] = $row["id_complejo"];
$vec["$reg"]["activo"] = $row["activo"];
$reg++;
}
mysql_free_result($rs);
if(isset($vec)){
return $vec;
}else{
return false;
}
}
This array I keep in a variable within an iteration.
foreach($arrayComplejo as $key=>$complejo){
$arrayCabana = $cabana->buscarPorComplejo($complejo['id']);
}
On the second pass, I get the following error:
"PHP Fatal error: Call to a member function buscarPorComplejo() on array in ...."
I already tried cleaning the variable with unset but I can not avoid this error, any idea?