I have this MySQL table:

Where I want to get count of each platform (windows, linux, mac, unknown).
Notice that in table is no mac or unknown data, there for num will be 0
Conditions:
- order must be like in wanted output
- check if plaform is in table, if not add zero to output
Question: How to sort in query to have order like in wanted output, and add zero if no platform in table?
Wanted output:
array (
'0' => array('name' => 'windows', 'num' => 3),
'1' => array('name' => 'linux', 'num' => 3),
'2' => array('name' => 'mac', 'num' => 0),
'3' => array('name' => 'unknown', 'num' => 0)
);
My try:
PHP:
function get_platforms() {
$query = "
SELECT platform, COUNT(platform) AS num
FROM stats
GROUP BY platform
ORDER BY platform ASC
";
$select = mysqli_query($this->c, $query);
while ($row = mysqli_fetch_array($select)) {
$data[] = array(
'name' => $row['platform'],
'num' => $row['num']
);
}
return $data;
}
Current outpup:
array (
'0' => array ('name' => 'linux', 'num' => 3)
'1' => array ('name' => 'windows', 'num' => 3)
);
Platforms?