function privatemsg_sql_load in Privatemsg 6
Same name and namespace in other branches
- 6.2 privatemsg.module \privatemsg_sql_load()
Query function for loading a single or multiple messages.
Parameters
$fragments: Query fragments array.
$pmids: Array of pmids.
$account: Account for which the messages should be loaded.
Related topics
File
- ./
privatemsg.module, line 1212 - Allows users to send private messages to other users.
Code
function privatemsg_sql_load(&$fragments, $pmids, $account = NULL) {
$fragments['primary_table'] = '{pm_message} pm';
$fragments['select'][] = "pm.mid";
$fragments['select'][] = "pm.author";
$fragments['select'][] = "pm.subject";
$fragments['select'][] = "pm.body";
$fragments['select'][] = "pm.timestamp";
$fragments['select'][] = "pm.format";
$fragments['select'][] = "pmi.is_new";
$fragments['select'][] = "pmi.thread_id";
$fragments['inner_join'][] = 'INNER JOIN {pm_index} pmi ON pm.mid = pmi.mid';
// Use IN() to load multiple messages at the same time.
$fragments['where'][] = 'pmi.mid IN (' . db_placeholders($pmids) . ')';
$fragments['query_args']['where'] += $pmids;
if ($account) {
$fragments['where'][] = 'pmi.uid = %d';
$fragments['query_args']['where'][] = $account->uid;
}
$fragments['order_by'][] = 'pm.timestamp ASC';
$fragments['order_by'][] = 'pm.mid ASC';
}