You are here

function _votingapi_query in Voting API 6.2

Same name and namespace in other branches
  1. 6 votingapi.module \_votingapi_query()

Internal helper function constructs WHERE clauses. Don't use unless you're me.

2 calls to _votingapi_query()
_votingapi_delete in ./votingapi.module
Internal helper function constructs DELETE queries. Don't use unless you're me.
_votingapi_select in ./votingapi.module
Internal helper function constructs SELECT queries. Don't use unless you're me.

File

./votingapi.module, line 602
A generalized voting API for Drupal.

Code

function _votingapi_query($table = 'vote', $criteria = array(), $alias = 'v.') {
  $criteria += array(
    'vote_id' => NULL,
    'vote_cache_id' => NULL,
    'content_id' => NULL,
    'content_type' => NULL,
    'value_type' => NULL,
    'value' => NULL,
    'tag' => NULL,
    'uid' => NULL,
    'timestamp' => NULL,
    'vote_source' => NULL,
    'function' => NULL,
  );
  $query = '';
  $args = array();
  if (!empty($criteria['vote_id'])) {
    _votingapi_query_builder($alias . 'vote_id', $criteria['vote_id'], $query, $args);
  }
  elseif (!empty($criteria['vote_cache_id'])) {
    _votingapi_query_builder($alias . 'vote_cache_id', $criteria['vote_cache_id'], $query, $args);
  }
  else {
    _votingapi_query_builder($alias . 'content_type', $criteria['content_type'], $query, $args, TRUE);
    _votingapi_query_builder($alias . 'content_id', $criteria['content_id'], $query, $args);
    _votingapi_query_builder($alias . 'value_type', $criteria['value_type'], $query, $args, TRUE);
    _votingapi_query_builder($alias . 'tag', $criteria['tag'], $query, $args, TRUE);
    _votingapi_query_builder($alias . 'function', $criteria['function'], $query, $args, TRUE);
    _votingapi_query_builder($alias . 'uid', $criteria['uid'], $query, $args);
    _votingapi_query_builder($alias . 'vote_source', $criteria['vote_source'], $query, $args, TRUE);
    _votingapi_query_builder($alias . 'timestamp', $criteria['timestamp'], $query, $args);
  }
  return array(
    'query' => $query,
    'args' => $args,
  );
}