Given the code:
$counters = $db->query("SELECT COUNT(film_id) FROM review WHERE film_id = $film_id ");
I need to convert the object $counters into an integer. FYI: the query returns a single int i.e 4 (depending on the film_ID)
Given the code:
$counters = $db->query("SELECT COUNT(film_id) FROM review WHERE film_id = $film_id ");
I need to convert the object $counters into an integer. FYI: the query returns a single int i.e 4 (depending on the film_ID)
Give an alias to the column that stores the COUNT result then use it as you would use with any other SELECT query.
$counters = $db->query("SELECT COUNT(film_id) AS counter FROM review WHERE film_id = $film_id "); $counter = $counters->fetch_assoc(); echo $counter['counter'];