function Tables::getTableMapping

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/Query/Sql/Tables.php \Drupal\Core\Entity\Query\Sql\Tables::getTableMapping()
  2. 10 core/lib/Drupal/Core/Entity/Query/Sql/Tables.php \Drupal\Core\Entity\Query\Sql\Tables::getTableMapping()
  3. 11.x core/lib/Drupal/Core/Entity/Query/Sql/Tables.php \Drupal\Core\Entity\Query\Sql\Tables::getTableMapping()

Gets the schema for the given table.

Parameters

string $table: The table name.

Return value

array|false An associative array of table field mapping for the given table, keyed by columns name and values are just incrementing integers. If the table mapping is not available, FALSE is returned.

1 call to Tables::getTableMapping()
Tables::addField in core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
Adds a field to a database query.

File

core/lib/Drupal/Core/Entity/Query/Sql/Tables.php, line 444

Class

Tables
Adds tables and fields to the SQL entity query.

Namespace

Drupal\Core\Entity\Query\Sql

Code

protected function getTableMapping($table, $entity_type_id) {
    $storage = $this->entityTypeManager
        ->getStorage($entity_type_id);
    if ($storage instanceof SqlEntityStorageInterface) {
        $mapping = $storage->getTableMapping()
            ->getAllColumns($table);
    }
    else {
        return FALSE;
    }
    return array_flip($mapping);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.