I see other tutorials on counting rows, but none on counting specific rows $row[scope] for specific results. How can this be done?
function counting(){
$query = "SELECT *
FROM table";
$result->fetchAll($sql, $params);
$num_rows = count($result);
$counter = 0;
//while($row = mysql_fetch_array($result)){ //old code
foreach($result as $row){
if($row[scope] == "all"){
$counter++;
}
}
$return = ($counter > 0)?TRUE:FALSE;
}
protected function fetchAll($sql, $params)
{
$stmt = $this->dbh->prepare($sql);
$stmt->execute($params);
return $stmt->fetchALL(DatabaseAdapter::FETCH_ASSOC);
}
SELECT * FROM table where scope = 'all';-- At that point you won't need PHP to filter itselect count(*) as theCount from myTable where scope='all'