$db = $this->db->getNewInstance(); // возможно $db = $this->db->update('view_journal');
$db->where('id_journal', $id);
$db->where('id_object', $objectID);
$db->where('id_pupil', $pupilID);
$db->where('date', $date);
$db->set('rating', $rating);
$db->update('view_journal');
$db->exec();
INSERT INTO
table
SET
`id` = ?,
`title` = ?,
`text` = ?,
`hash`= ?
ON DUPLICATE KEY UPDATE
id= ?
SELECT `id`, `date`,
sum(if(Android is null,0,1)) as android,
sum(if(Android is null,1,0)) as empty_android
FROM `vote`
GROUP BY DATE_FORMAT(`date`, '%Y-%M-%D')
SELECT `id`, `date`,
sum(if(Android <> '',0,1)) as android,
sum(if(Android = '', 1,0)) as empty_android
FROM `vote`
GROUP BY DATE_FORMAT(`date`, '%Y-%M-%D')