You are here

function privatemsg_sql_deleted in Privatemsg 7

Same name and namespace in other branches
  1. 6.2 privatemsg.module \privatemsg_sql_deleted()
  2. 6 privatemsg.module \privatemsg_sql_deleted()
  3. 7.2 privatemsg.module \privatemsg_sql_deleted()

Query Builder function to load all messages that should be flushed.

Parameters

$days: Select messages older than x days.

$max: Select no more than $max messages.

See also

hook_query_privatemsg_deleted_alter()

Related topics

File

./privatemsg.module, line 1229
Allows users to send private messages to other users.

Code

function privatemsg_sql_deleted($days, $max) {
  $query = db_select('pm_message', 'pm');
  $query
    ->addField('pm', 'mid');
  $query
    ->join('pm_index', 'pmi', 'pmi.mid = pm.mid');
  return $query
    ->groupBy('pm.mid')
    ->having('MIN(pmi.deleted) > 0 AND MAX(pmi.deleted) < :old', array(
    ':old' => REQUEST_TIME - $days * 86400,
  ))
    ->range(0, $max);
}