I've got an PDO connecting which executes a query, but in don't know how to read the fetched result, the result comes back as an object instead of an array.
$query = $MyPDO->query("SELECT count(ID) FROM score WHERE totalscore>? AND competition=?",$data['totalscore'],$data['competition']);
//$fetch = $query->fetch();
while($fetch = $query->fetch()){
var_dump($fetch);
}
And the result is:
object(stdClass)#3 (1) { ["count(ID)"]=> string(2) "27" }
Can anyone tell me how to read this? $fetch["count(ID)"]
did not work, $fetch[0]
neither.
Use SELECT count(ID) as count...
and $fetch->count
.