You are here

function _votingapi_query_builder in Voting API 6

Same name and namespace in other branches
  1. 6.2 votingapi.module \_votingapi_query_builder()
1 call to _votingapi_query_builder()
_votingapi_query in ./votingapi.module

File

./votingapi.module, line 496

Code

function _votingapi_query_builder($name, $value, &$query, &$args, $col_is_string = FALSE) {
  if (!isset($value)) {

    // Do nothing
  }
  elseif ($name === 'timestamp') {
    $query .= " AND v.timestamp >= %d";
    $args[] = $value;
  }
  else {
    if (is_array($value)) {
      if ($col_is_string) {
        $query .= " AND v." . $name . " IN ('" . array_fill(1, count($value), "'%s'") . "')";
        $args += $value;
      }
      else {
        $query .= " AND v." . $name . " IN (" . array_fill(1, count($value), "%d") . ")";
        $args += $value;
      }
    }
    else {
      if ($col_is_string) {
        $query .= " AND v." . $name . " = '%s'";
        $args[] = $value;
      }
      else {
        $query .= " AND v." . $name . " = %d";
        $args[] = $value;
      }
    }
  }
}