You are here

function privatemsg_attachments_sql_count in Privatemsg 6.2

File

privatemsg_attachments/privatemsg_attachments.module, line 371
Allows users to add attachments to messages

Code

function privatemsg_attachments_sql_count(&$fragments, $threads) {
  $fragments['primary_table'] = '{pm_attachments} pma';
  $fragments['select'][] = 'pmi.thread_id';
  $fragments['select'][] = 'COUNT(DISTINCT pma.fid) AS count';
  $fragments['inner_join'][] = 'INNER JOIN {pm_index} pmi ON (pmi.mid = pma.mid)';
  $fragments['where'][] = 'pmi.thread_id IN (' . db_placeholders($threads) . ')';
  $fragments['query_args']['where'] = $threads;
  $fragments['group_by'][] = 'pmi.thread_id';
}