public function SelectQuery::addField

cis7 select.inc public SelectQuery::addField($table_alias, $field, $alias = NULL)
cle7 select.inc public SelectQuery::addField($table_alias, $field, $alias = NULL)
elmsmedia7 select.inc public SelectQuery::addField($table_alias, $field, $alias = NULL)
icor7 select.inc public SelectQuery::addField($table_alias, $field, $alias = NULL)
meedjum_blog7 select.inc public SelectQuery::addField($table_alias, $field, $alias = NULL)
mooc7 select.inc public SelectQuery::addField($table_alias, $field, $alias = NULL)

Adds a field to the list to be SELECTed.

Parameters

$table_alias: The name of the table from which the field comes, as an alias. Generally you will want to use the return value of join() here to ensure that it is valid.

$field: The name of the field.

$alias: The alias for this field. If not specified, one will be generated automatically based on the $table_alias and $field. The alias will be checked for uniqueness, so the requested alias may not be the alias that is assigned in all cases.

Return value

The unique alias that was assigned for this field.

Overrides SelectQueryInterface::addField

2 calls to SelectQuery::addField()
SelectQuery::fields in includes/database/select.inc
Add multiple fields from the same table to be SELECTed.
SelectQuery_pgsql::orderBy in includes/database/pgsql/select.inc
Overrides SelectQuery::orderBy().

File

includes/database/select.inc, line 1272

Class

SelectQuery
Query builder for SELECT statements.

Code

public function addField($table_alias, $field, $alias = NULL) {
  // If no alias is specified, first try the field name itself.
  if (empty($alias)) {
    $alias = $field;
  }

  // If that's already in use, try the table name and field name.
  if (!empty($this->fields[$alias])) {
    $alias = $table_alias . '_' . $field;
  }

  // If that is already used, just add a counter until we find an unused alias.
  $alias_candidate = $alias;
  $count = 2;
  while (!empty($this->fields[$alias_candidate])) {
    $alias_candidate = $alias . '_' . $count++;
  }
  $alias = $alias_candidate;

  $this->fields[$alias] = array(
    'field' => $field,
    'table' => $table_alias,
    'alias' => $alias,
  );

  return $alias;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.