I'm doing a query on the model of a web application in PHP
with MVC
. The idea is to make a query in which to put the value in empresa_id
I see the total rows with that company, for this I used COUNT()
in the query SQL
.
The error that throws me is that company 14 has for example 8 users, and the function only shows me a 1.
How can I make the company total 14 appear?
public function Contador(){
try{
//Sentencia SQL.
$sql = "SELECT COUNT(id) AS codigo
FROM nombre_tabla
WHERE empresa_id = '14'";
$stm = $this->pdo->prepare($sql);
$stm->execute();
return $stm->rowCount();
} catch (Exception $e){
die($e->getMessage());
}
}