You are here

function messaging_store_get in Messaging 5

Same name and namespace in other branches
  1. 6 messaging.store.inc \messaging_store_get()
  2. 6.2 messaging.store.inc \messaging_store_get()
  3. 6.3 messaging.store.inc \messaging_store_get()

Retrieve from messaging database storage

Parameters

$params: Array of field value pairs

$order: Optional array of field names to order by

$limit: Optional maximum number of rows to retrieve

$pager: Optional pager element for pager queries

$unpack: Optional fully load stored data

1 call to messaging_store_get()
messaging_store_pull_pending in ./messaging.store.inc
Get pending messages for method

File

./messaging.store.inc, line 114
Database storage for the messaging framework

Code

function messaging_store_get($params, $order = NULL, $limit = NULL, $pager = NULL, $unpack = FALSE) {
  $messages = $where = $args = array();
  list($where, $args) = messaging_store_query($params);
  $sql = 'SELECT * FROM {messaging_store}';
  $sql .= $where ? ' WHERE ' . implode(' AND ', $where) : '';
  $sql .= $order ? ' ORDER BY ' . implode(', ', $order) : '';
  if (!is_null($pager)) {
    $result = pager_query($sql, $limit, $pager, NULL, $args);
  }
  elseif ($limit) {
    $result = db_query_range($sql, $args, 0, $limit);
  }
  else {
    $result = db_query($sql, $args);
  }
  while ($msg = db_fetch_array($result)) {
    messaging_store_unpack($msg, $unpack);
    $messages[$msg['mqid']] = $msg;
  }
  return $messages;
}