When I upload a video in my website, its size is saved in the database. And then, I use these functions to get the amount of gygabites left in the account used.
public static function Capacidad($user){
$sql = "SELECT tipocuenta.id, tipocuenta.capacidad FROM tipocuenta, canal WHERE tipocuenta.id = canal.id_tipocuenta AND canal.id = '$user'";
$resultado = self::Conexion($sql);
if(isset($resultado)){ $datos = $resultado->fetch(); }
$capacidad = $datos["capacidad"];
return $capacidad;
}
public static function CapacidadUsada($user){
$sql = "SELECT sum(tamaño) FROM video WHERE usuario_id = '$user'";
$resultado = self::Conexion($sql);
return $resultado;
}
public static function CapacidadUsadaGB(){
$capacidad_total = Database::Capacidad($_SESSION["usuario"]);
$capacidad_usada = Database::CapacidadUsada($_SESSION["usuario"]);
$capacidad_usadaGB = number_format($capacidad_usada / 1073741824, 2)."GB";
return $capacidad_usadaGB;
}
I get the amount of GB that an user can use and the amount of GB that the user have used uploading videos. But it doesnt work... It prints me this error:
Notice: Object of class PDOStatement could not be converted to int