public static function Notifications_Subscription::select_subscriptions in Notifications 7
Query for selecting multiple subscriptions
Parameters
array $conditions: Array of multiple conditions in the notifications table to delete subscriptions
array $field_conditions: Array of field objects or multiple (type => value) conditions in the notifications_subscription_fields table to delete subscriptions
$limit: Whether to limit the result to subscriptions with exactly that condition fields
3 calls to Notifications_Subscription::select_subscriptions()
- Notifications_Subscription::delete_multiple in ./
notifications.subscription.inc - Delete multiple subscriptions and clean up related data (pending notifications, fields).
- Notifications_Subscription::load_multiple in ./
notifications.subscription.inc - Load multiple from db
- Notifications_Subscription::load_single in ./
notifications.subscription.inc - Load single subscription from db
File
- ./
notifications.subscription.inc, line 819 - Drupal Notifications Framework - Default class file
Class
- Notifications_Subscription
- Common base for subscription type and subscription instance
Code
public static function select_subscriptions($conditions, $field_conditions = array(), $limit = FALSE) {
$query = db_select('notifications_subscription', 's')
->fields('s', array(
'sid',
));
foreach ($conditions as $field => $value) {
if (is_object($value)) {
$query
->condition($value);
}
else {
// This is a field => value pair
$query
->condition('s.' . $field, $value);
}
}
// For exact condition fields we add one more main condition.
if ($limit) {
$query
->condition('conditions', count($field_conditions));
}
if ($field_conditions) {
$count = 0;
foreach ($field_conditions as $type => $field) {
$alias = 'f' . $count++;
$query
->join('notifications_subscription_fields', $alias, "s.sid = {$alias}.sid");
if (is_object($field)) {
$query
->condition($field
->get_query_condition($alias));
}
else {
$query
->condition($alias . '.type', $type);
$query
->condition($alias . '.value', $field);
}
}
}
return $query;
}