I'm trying to create a query as follows:
I have a table in the database with this structure:
name | address | status
The status field only has 2 types of values 1 or 0. I want to count all records that have status 0
I made the following query:
select count(*) as total from sv_mensagens where status = 0
In PHP I made the following code using PDO:
$this->pdo = ConnDB::conexao();
$query3 = "select count(*) as total from sv_mensagens where status = 0";
$conta2 = $this->pdo->prepare($query3);
$conta2->execute();
while ($result = $conta2->fetchAll()){
echo $result['total'];
}
Only error occurs and does not work What I want to bring is the result of counting all the records that have the status at 0.