function simplenews_update_7010 in Simplenews 7
Same name and namespace in other branches
- 7.2 simplenews.install \simplenews_update_7010()
Update empty sent subscriber count column to current subscriber count.
File
- ./
simplenews.install, line 876 - Install, update and uninstall functions for the simplenews module
Code
function simplenews_update_7010() {
// Assume that already sent newsletters that have a sent subscriber count of
// 0 have been sent to all subscribers. Do a update query per newsletter
// category, to avoid having to re-execute the subquery on every row.
$tids = db_query('SELECT tid FROM {simplenews_category}')
->fetchCol();
foreach ($tids as $tid) {
$count = db_query('SELECT COUNT(*) FROM {simplenews_subscription} ss WHERE status = 1 AND tid = :tid', array(
':tid' => $tid,
))
->fetchField();
db_update('simplenews_newsletter')
->fields(array(
'sent_subscriber_count' => $count,
))
->condition('status', 2)
->condition('sent_subscriber_count', 0)
->condition('tid', $tid)
->execute();
}
}