You are here

function quotes_block_join_sql in Quotes 5

Same name and namespace in other branches
  1. 6 quotes.module \quotes_block_join_sql()
  2. 7 quotes.module \quotes_block_join_sql()

Returns the SQL join text necessary for the provided filter criteria.

Parameters

$filters: The array specifying filter criteria using the keys nid_filter, aid_filter, rid_filter, uid_filter, and tid_filter.

$aliases: The array specifying the aliases to be used for the tables that may be joined based on the provided filter criteria. Keys are the table names node, users_roles, users, and term_node.

Return value

A string containing the SQL join text necessary for the provided criteria.

1 call to quotes_block_join_sql()
quotes_get_quote in ./quotes.module
Returns the node ID for either a random quote or the most recent quote based on the provided filter criteria.

File

./quotes.module, line 1321

Code

function quotes_block_join_sql($filters = array(), $aliases = array(
  'node' => 'n',
  'users_roles' => 'qur',
  'users' => 'qu',
  'term_node' => 'qtn',
)) {
  $join = '';
  if ($filters['rid_filter']) {
    $join .= " LEFT JOIN {users_roles} {$aliases['users_roles']} ON {$aliases['users_roles']}.uid = {$aliases['node']}.uid ";
  }
  if ($filters['tid_filter']) {
    $join .= " INNER JOIN {term_node} {$aliases['term_node']} ON {$aliases['term_node']}.nid = {$aliases['node']}.nid ";
  }
  return $join;
}