function privatemsg_sql_deleted

1 privatemsg.module privatemsg_sql_deleted(&$fragments, $days)
7-1 privatemsg.module privatemsg_sql_deleted($days, $max)
7-2 privatemsg.module privatemsg_sql_deleted($days, $max)
6-2 privatemsg.module privatemsg_sql_deleted(&$fragments, $days)

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 1215
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);
}