/** * Fetch number of recipients * * @return int */ public function getCount() { parent::getCount(); if (!is_null($this->newsletter_id)) { return -1; } $where_and_joins = $this->_getWhereAndJoins(); $count = Symphony::Database()->fetchCol('count', "SELECT count(`a`.`id`) as `count` FROM `tbl_authors` as `a` " . $where_and_joins['joins'] . ' WHERE 1 ' . $where_and_joins['where']); return $count[0]; }
/** * Fetch number of recipients * * @return int */ public function getCount() { parent::getCount(); if ($this->newsletter_id !== NULL) { return -1; } $this->_createTempTable(); $rows = Symphony::Database()->fetchCol('count', 'SELECT count(email) as count from ' . $this->_tempTable); return $rows[0]; }
/** * Fetch number of recipients * * @return int */ public function getCount() { parent::getCount(); // To get the exact count for the newsletter requires a very slow query. // This value is not used anywhere, so for performance reasons count will not return anything. if ($this->newsletter_id !== NULL) { return -1; } $where_and_joins = $this->getWhereJoinsAndGroup(true); try { $count = Symphony::Database()->fetchVar('count', 0, sprintf('SELECT SQL_CACHE count(DISTINCT `d`.`value`) as `count` FROM `tbl_entries` AS `e` %s %s', $where_and_joins['joins'], ' WHERE 1 ' . $where_and_joins['where'])); } catch (DatabaseException $e) { // Invalid, not supported field. Instead of giving an error we should just return 0 recipients. // This can be improved later to recognise the type of field, and adjust the query accordingly, but for now this will do. $count = 0; } return $count; }