public function DefaultTableMapping::getAllColumns

public DefaultTableMapping::getAllColumns($table_name)

Gets a list of all database columns for a given table.

Parameters

string $table_name: The name of the table to return the columns for.

Return value

string[] An array of database column names for this table. Both field columns and extra columns are returned.

Overrides TableMappingInterface::getAllColumns

File

core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php, line 102

Class

DefaultTableMapping
Defines a default table mapping class.

Namespace

Drupal\Core\Entity\Sql

Code

public function getAllColumns($table_name) {
  if (!isset($this->allColumns[$table_name])) {
    $this->allColumns[$table_name] = array();

    foreach ($this->getFieldNames($table_name) as $field_name) {
      $this->allColumns[$table_name] = array_merge($this->allColumns[$table_name], array_values($this->getColumnNames($field_name)));
    }

    // There is just one field for each dedicated storage table, thus
    // $field_name can only refer to it.
    if (isset($field_name) && $this->requiresDedicatedTableStorage($this->fieldStorageDefinitions[$field_name])) {
      // Unlike in shared storage tables, in dedicated ones field columns are
      // positioned last.
      $this->allColumns[$table_name] = array_merge($this->getExtraColumns($table_name), $this->allColumns[$table_name]);
    }
    else {
      $this->allColumns[$table_name] = array_merge($this->allColumns[$table_name], $this->getExtraColumns($table_name));
    }
  }
  return $this->allColumns[$table_name];
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Sql!DefaultTableMapping.php/function/DefaultTableMapping::getAllColumns/8.1.x