function messaging_store_query in Messaging 5
Same name and namespace in other branches
- 6 messaging.store.inc \messaging_store_query()
- 6.2 messaging.store.inc \messaging_store_query()
- 6.3 messaging.store.inc \messaging_store_query()
Build query with field conditions
This function supports IN() conditions when passing array field values
Parameters
$query: Array of field => value pars
3 calls to messaging_store_query()
- messaging_store_del in ./
messaging.store.inc - Delete messages from queue
- messaging_store_get in ./
messaging.store.inc - Retrieve from messaging database storage
- messaging_store_sent in ./
messaging.store.inc - Mark messages as sent, either deleting them, or keeping logs
File
- ./
messaging.store.inc, line 142 - Database storage for the messaging framework
Code
function messaging_store_query($fields) {
$where = $args = array();
foreach ($fields as $key => $value) {
if (is_array($value)) {
// Special processing for array parameters. Many ints are expected for 'mqid' field
$placeholder = $key == 'mqid' ? '%d' : "'%s'";
$where[] = "{$key} IN (" . implode(',', array_fill(0, count($value), $placeholder)) . ')';
$args = array_merge($args, $value);
}
else {
$where[] = $key . " = '%s'";
$args[] = $value;
}
}
return array(
$where,
$args,
);
}