Revert batch processing on bulk actions - too buggy

- minor fixes and cleanup
This commit is contained in:
Jonathan Labreuille
2016-05-27 14:07:54 +02:00
parent 3c46a5b434
commit 8292e9a744
4 changed files with 41 additions and 61 deletions

View File

@ -95,18 +95,24 @@ class SubscriberSegment extends Model {
}
// create many subscriptions to each segment
foreach($segment_ids as $segment_id) {
$query = array(
'INSERT IGNORE INTO `'.self::$_table.'`',
'(`subscriber_id`, `segment_id`, `status`)',
'VALUES '.rtrim(str_repeat(
"(?, ".(int)$segment_id.", '".Subscriber::STATUS_SUBSCRIBED."'), ",
count($subscriber_ids)
), ', ')
);
self::rawExecute(join(' ', $query), $subscriber_ids);
$values = array();
$row_count = 0;
foreach($segment_ids as &$segment_id) {
foreach($subscriber_ids as &$subscriber_id) {
$values[] = (int)$subscriber_id;
$values[] = (int)$segment_id;
$values[] = Subscriber::STATUS_SUBSCRIBED;
$row_count++;
}
}
$query = array(
'INSERT IGNORE INTO `'.self::$_table.'`',
'(`subscriber_id`, `segment_id`, `status`)',
'VALUES '.rtrim(str_repeat('(?, ?, ?), ', $row_count), ', ')
);
self::rawExecute(join(' ', $query), $values);
return true;
}