-
Task
-
Resolution: Won't Do
-
Minor
-
3.1.0-dev
-
None
The following queries can be combined easily
if ($options['count_unread'])
|
{
|
// Get the total number of unread notifications
|
$sql = 'SELECT COUNT(n.notification_id) AS unread_count
|
FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt
|
WHERE n.user_id = ' . (int) $options['user_id'] . '
|
AND n.notification_read = 0
|
AND nt.notification_type = n.item_type
|
AND nt.notification_type_enabled = 1';
|
$result = $this->db->sql_query($sql);
|
$unread_count = (int) $this->db->sql_fetchfield('unread_count', $result);
|
$this->db->sql_freeresult($result);
|
}
|
|
|
if ($options['count_total'])
|
{
|
// Get the total number of notifications
|
$sql = 'SELECT COUNT(n.notification_id) AS total_count
|
FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt
|
WHERE n.user_id = ' . (int) $options['user_id'] . '
|
AND nt.notification_type = n.item_type
|
AND nt.notification_type_enabled = 1';
|
$result = $this->db->sql_query($sql);
|
$total_count = (int) $this->db->sql_fetchfield('total_count', $result);
|
$this->db->sql_freeresult($result);
|
}
|

