You are here

function _signup_build_query in Signup 6

Same name and namespace in other branches
  1. 5.2 signup.module \_signup_build_query()
  2. 6.2 signup.module \_signup_build_query()
  3. 7 signup.module \_signup_build_query()

Private query builder helper function.

Parameters

$common_sql: Nested array of shared query fragments that are common to all date-based backends. The supported keys are: 'primary': the query's primary table and its alias (required). 'fields': array of fields to SELECT. 'joins': array of JOIN statements for other tables. 'where': array of WHERE clauses. 'group_by': array of GROUP BY fields.

$backend_sql: Similar nested array provided by the date-based backend include file, except that 'primary' is not allowed.

Return value

Complete SQL statement based on the given query fragments.

3 calls to _signup_build_query()
signup_admin_form_sql in includes/admin.signup_administration.inc
_signup_cron_autoclose in includes/cron.inc
Helper function that handles auto-closing time-based nodes during cron.
_signup_cron_send_reminders in includes/cron.inc
Helper function that sends cron-based reminder e-mails.

File

./signup.module, line 209
The Signup module (http://drupal.org/project/signup) manages replies to nodes. In particular, it's good for event management. Signup supports sending reminder emails and automatically closing signups for nodes with a start time, via the Event…

Code

function _signup_build_query($common_sql, $type_sql) {

  // Combine type-specific sql with common_sql.
  $full_sql = array_merge_recursive($common_sql, $type_sql);
  $sql = 'SELECT ' . implode(', ', $full_sql['fields']);
  $sql .= ' FROM ' . $common_sql['primary'] . ' ';
  if (!empty($full_sql['joins'])) {
    $sql .= implode(' ', $full_sql['joins']);
  }
  if (!empty($full_sql['where'])) {
    $sql .= ' WHERE (' . implode(') AND (', $full_sql['where']) . ')';
  }
  if (!empty($full_sql['group_by'])) {
    $sql .= ' GROUP BY ' . implode(', ', $full_sql['group_by']);
  }
  return $sql;
}