Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-11447

Combine count_unread and count_total queries in phpbb_notification_manager

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Won't Do
    • Icon: Minor Minor
    • 3.1.12-RC1
    • 3.1.0-dev
    • Notification System
    • 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);
      		}
      

            CHItA CHItA
            bantu Andreas Fischer [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: