function getTopicsEmailsCount($topics_ids, $unique = true) { global $application; if (empty($topics_ids)) { return array(); } $tables = $this->getTables(); $etable = 'subscription_email'; $ecolumns =& $tables[$etable]['columns']; $query = new DB_Select($etable); if ($unique) { $query->addSelectField(DB_Select::fCountDistinct($ecolumns['email_id']), 'email_count'); } else { $query->addSelectField(DB_Select::fCount($ecolumns['email_id']), 'email_count'); } $query->Where($ecolumns['topic_id'], DB_IN, DBQuery::arrayToIn($topics_ids)); $res = $application->db->getDB_Result($query); return $res[0]['email_count']; }