You are here

function messaging_store_query in Messaging 6

Same name and namespace in other branches
  1. 5 messaging.store.inc \messaging_store_query()
  2. 6.2 messaging.store.inc \messaging_store_query()
  3. 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 152
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
      $type = $key == 'mqid' ? 'int' : 'varchar';
      $where[] = $key . ' IN(' . db_placeholders($value, $type) . ')';
      $args = array_merge($args, $value);
    }
    else {
      $where[] = $key . " = '%s'";
      $args[] = $value;
    }
  }
  return array(
    $where,
    $args,
  );
}