So, there are a lot of similar questions about this, but in the application I can’t get it right... And I’m confused, because it’s working on other functions...
So... the code has a constructor like this...
public function getMontoDescuentosRealizados($idPropiedad, $idArriendo, $idEstado = 4, $idTipoReceptor = 1)
{
$db = $this->db;
$strWhere = ($idArriendo > 0) ? " AND ard.IDArriendoGarantia='" . $idArriendo . "'" : "";
$query = "SELECT SUM(ardd.MontoCuota) as Descuento
FROM descuentos_consolidados as ard
INNER JOIN cuotas_consolidados AS ardd ON (ard.IDConsolidado=ardd.IDConsolidado AND ardd.nCuota=0)
WHERE ard.Autorizado IN (1)
AND ard.IDPropiedad=" . $idPropiedad . $strWhere;
#error_log($query);
$sql = $db->query($query);
$row = $sql->fetch_array();
return ($row["Descuento"] > 0) ? $row["Descuento"] : 0;
}
And there is just one function, that doesn’t work properly... and I don’t know what more I can do... I tried some solutions, but they don’t seem to fix the problem...
This is the Stack Overflow question that I’d been checking a lot: PHP Fatal error: Using $this when not in object context