@param string|null $tableName

@return FinalizedMapperDefinition
@throws IncompleteMapperDefinitionException
325904
public function finalize(string $tableName = null): FinalizedMapperDefinition
    {
        $this->verifyDefinedClass();

        $tableName = $tableName ?: $this->tableName;

        $allMappedProperties = $this->getAllMappedProperties();

        foreach ($this->class->getProperties() as $property) {
            $propertyName = $property->getName();

            if ($this->verifyAllPropertiesMapped && !isset($allMappedProperties[$propertyName])) {
                throw IncompleteMapperDefinitionException::format(
                    'Invalid mapper definition for %s: unmapped property \'%s\' of type %s, call $map->ignoreUnmappedProperties() to ignore this warning',
                    $this->class->getClassName(),
                    $propertyName,
                    $property->getType()->asTypeString()
                );
            }
        }

        $table = new Table(
            $this->orm->getNamespace() . $tableName,
            $this->columns,
            $this->indexes,
            $this->foreignKeys
        );

        $relationsFactory = function (Table $table, IObjectMapper $parentMapper) {
            $objectType = $parentMapper->getObjectType();
            $tableName  = $parentMapper->getDefinition()->getTable()->getName();

            $relations = [];
            foreach ($this->relationFactories as $factory) {
                $relationId  = implode(':', [$objectType, $tableName, $this->getRootDefinition()->relationCount++]);
                $relations[] = $factory($relationId, $table, $parentMapper);
            }

            return $relations;
        };

        $foreignKeysFactory = function (Table $table) {
            $foreignKeys = [];

            foreach ($this->foreignKeyFactories as $factory) {
                /** @var ForeignKey $foreignKey */
                $foreignKey    = $factory($table);
                $foreignKeys[] = $foreignKey->withNamePrefixedBy($this->orm->getNamespace());
            }

            return $foreignKeys;
        };

        $persistHooks = [];
        foreach ($this->persistHookFactories as $uniqueKey => $factory) {
            $persistHooks[] = $factory($table, $uniqueKey, $this->propertyColumnMap, $this->class->getClassName());
        }

        $subClassMappings = [];
        foreach ($this->subClassMappingFactories as $factory) {
            $subClassMappings[] = $factory($table);
        }

        return new FinalizedMapperDefinition(
            $this->orm,
            $this->class,
            $table,
            $this->propertyColumnMap,
            $this->columnGetterMap,
            $this->columnSetterMap,
            $this->phpToDbPropertyConverterMap,
            $this->dbToPhpPropertyConverterMap,
            $this->methodColumnMap,
            $this->customLoadMappingCallbacks,
            $this->lockingStrategies,
            $persistHooks,
            $subClassMappings,
            $relationsFactory,
            $foreignKeysFactory
        );
    }
763468
public function getTablePk($tableName) {
        $details = $this->getTableColumns($tableName);
        $pk = [];
        foreach ($details as $column) {
            if ($column['Key'] == 'PRI') {
                $pk[] =  $column['Field'];
            }
        }
        if (1 == count($pk)){
            return $pk[0];
        } elseif (count($pk)) {
            return $pk;
        }
        return null;
    }
380324
protected function tableMaybeInvalid($tableName) : string
    {
        if (!is_string($tableName)) {
            throw new \InvalidArgumentException(
                'Invalid table name type. Table name must be as string',
                E_USER_ERROR
            );
        }

        $tableName = trim($tableName);
        if ($tableName == '') {
            throw new \InvalidArgumentException(
                'Invalid parameter table name. Table name could not be empty.',
                E_USER_ERROR
            );
        }

        return $tableName;
    }
14147
protected function mapExists(array $map, $modelName, $tableName = null)
    {
        // First we try to find an entry by model-name
        // if not found, we try to find one using the table-name if a value is provided
        $found = isset($map['model-name']) && $map['model-name'] == $modelName;

        if (!$found && !empty($tableName)) {
            $found = isset($map['table-name']) && $map['table-name'] == $tableName;
        }

        return $found;
    }
1127845
public function getTable($tableName)
    {
        if (is_array($tableName)) {
            list($tableName, $entitySuffix) = $tableName;
        } else {
            $entitySuffix = null;
        }

        if ($entitySuffix !== null) {
            $tableName .= '_' . $entitySuffix;
        }

        if (!isset($this->_tables[$tableName])) {
            $this->_tables[$tableName] = $this->_resources->getTableName(
                $tableName,
                ResourceConnection::DEFAULT_CONNECTION
            );
        }

        return $this->_tables[$tableName];
    }
1226899
private function getTableColumns (string $tableName)
    {
        $columns = DB::getSchemaBuilder ()->getColumnListing ($tableName);

        if (!count ($columns))
            $this->abort ("Table not found: " . $tableName);
        else
            $columns = DB::select (DB::raw ('SHOW COLUMNS FROM ' . $tableName));


        return $columns;
    }
323500
private function getClassNameForTable($tableName)
    {
        if (isset($this->classNamesForTables[$tableName])) {
            return $this->namespace . $this->classNamesForTables[$tableName];
        }

        return $this->namespace . Inflector::classify(strtolower($tableName));
    }
593433
protected function _getLanguageSetTables($coreTableName = null)
    {
        $coreTableName = $coreTableName ? $coreTableName : $this->getCoreTableName();

        return oxNew(\OxidEsales\Eshop\Core\DbMetaDataHandler::class)->getAllMultiTables($coreTableName);
    }
1146411
public static function buildTableMap()
    {
      $dbMap = Propel::getDatabaseMap(BaseUserCustomerRelationPeer::DATABASE_NAME);
      if (!$dbMap->hasTable(BaseUserCustomerRelationPeer::TABLE_NAME)) {
        $dbMap->addTableObject(new \Slashworks\AppBundle\Model\map\UserCustomerRelationTableMap());
      }
    }
382669
public function createTable($tableName)
    {
        $table = new Table($tableName);
        $this->_addTable($table);

        foreach ($this->_schemaConfig->getDefaultTableOptions() as $name => $value) {
            $table->addOption($name, $value);
        }

        return $table;
    }
1359456
public function withColumnsPrefixedBy(string $prefix): FinalizedMapperDefinition
    {
        if ($prefix === '') {
            return $this;
        }

        $table       = $this->table->withColumnsPrefixedBy($prefix);
        $entityTable = $this->entityTable->withColumnsPrefixedBy($prefix);

        $propertyColumnNameMap = [];
        foreach ($this->propertyColumnNameMap as $property => $column) {
            $propertyColumnNameMap[$property] = $prefix . $column;
        }

        $columnGetterMap = [];
        foreach ($this->columnGetterMap as $column => $getter) {
            $columnGetterMap[$prefix . $column] = $getter;
        }

        $columnSetterMap = [];
        foreach ($this->columnSetterMap as $column => $setter) {
            $columnSetterMap[$prefix . $column] = $setter;
        }

        $methodColumnNameMap = [];
        foreach ($this->methodColumnNameMap as $property => $column) {
            $methodColumnNameMap[$property] = $prefix . $column;
        }

        $lockingStrategies = [];
        foreach ($this->lockingStrategies as $key => $lockingStrategy) {
            $lockingStrategies[$key] = $lockingStrategy->withColumnNamesPrefixedBy($prefix);
        }

        $persistHooks = [];
        foreach ($this->persistHooks as $key => $persistHook) {
            $persistHooks[$key] = $persistHook->withColumnNamesPrefixedBy($prefix);
        }

        if ($this->hasInitializedRelations) {
            $relationMappingsFactory = function () {
                return $this->getRelationMappings();
            };

            $foreignKeyFactory = function () {
                return [];
            };
        } else {
            $relationMappingsFactory = $this->relationMappingsFactory;
            $foreignKeyFactory       = $this->foreignKeysFactory;
        }

        $relationMappingsFactory = function (Table $parentTable, IObjectMapper $parentMapper) use ($relationMappingsFactory, $prefix) {
            $mappings = [];

            /** @var RelationMapping $mapping */
            foreach ($relationMappingsFactory($parentTable, $parentMapper) as $mapping) {
                $mappings[] = $mapping->withEmbeddedColumnsPrefixedBy($prefix);
            }

            return $mappings;
        };

        $foreignKeyFactory = function (Table $parentTable) use ($foreignKeyFactory, $prefix) {
            $foreignKeys = [];
            /** @var ForeignKey $foreignKey */
            foreach ($foreignKeyFactory($parentTable) as $foreignKey) {
                $foreignKeys[] = $foreignKey->withLocalColumnsPrefixedBy($prefix);
            }

            return $foreignKeys;
        };

        $subClassMappings = [];
        foreach ($this->subClassMappings as $mapping) {
            $subClassMappings[] = $mapping->withEmbeddedColumnsPrefixedBy($prefix);
        }

        $self = new self(
            $this->orm,
            $this->class,
            $table,
            $propertyColumnNameMap,
            $columnGetterMap,
            $columnSetterMap,
            $this->phpToDbPropertyConverterMap,
            $this->dbToPhpPropertyConverterMap,
            $methodColumnNameMap,
            $this->customLoadMappingCallbacks,
            $lockingStrategies,
            $persistHooks,
            $subClassMappings,
            $relationMappingsFactory,
            $foreignKeyFactory,
            $entityTable
        );

        if ($this->hasInitializedRelations) {
            $self->initializeRelations(new NullObjectMapper());
        }

        return $self;
    }
808416
protected function getDBRouter($tableName, $suffix) {
        $rs = array('prefix' => '', 'key' => '', 'pdo' => NULL, 'isNoSuffix' => FALSE);

        if (preg_match('/^(\S+)\.(\S+)$/', $tableName, $match)) {
            $server = $match[1];
            if (!isset($this->_configs['tables'][$tableName])) {
                $this->_configs['tables'][$tableName] = array('map' => array(array('db' => $server)));
            }
        }

        $defaultMap = !empty($this->_configs['tables']['__default__']) 
            ? $this->_configs['tables']['__default__'] : array();
        $tableMap = !empty($this->_configs['tables'][$tableName]) 
            ? $this->_configs['tables'][$tableName] : $defaultMap;

        if (empty($tableMap)) {
            throw new InternalServerErrorException(
                \PhalApi\T('No table map config for {tableName}', array('tableName' => $tableName))
            );
        }

        $dbKey = NULL;
        $dbDefaultKey = NULL;
        if (!isset($tableMap['map'])) {
            $tableMap['map'] = array();
        }
        foreach ($tableMap['map'] as $map) {
            $isMatch = FALSE;

            if ((isset($map['start']) && isset($map['end']))) {
                if ($suffix !== NULL && $suffix >= $map['start'] && $suffix <= $map['end']) {
                    $isMatch = TRUE;
                }
            } else {
                $dbDefaultKey = $map['db'];
                if ($suffix === NULL) {
                    $isMatch = TRUE;
                }
            }

            if ($isMatch) {
                $dbKey = isset($map['db']) ? trim($map['db']) : NULL;
                break;
            }
        }
        //try to usdbKeye default map if no perfect match
        if ($dbKey === NULL) {
            $dbKey = $dbDefaultKey;
            $rs['isNoSuffix'] = TRUE;
        }

        if ($dbKey === NULL) {
            throw new InternalServerErrorException(
                \PhalApi\T('No db router match for {tableName}', array('tableName' => $tableName))
            );
        }

        $rs['pdo'] = $this->getPdo($dbKey);
        $rs['prefix'] = isset($tableMap['prefix']) ? trim($tableMap['prefix']) : '';
        $rs['key'] = isset($tableMap['key']) ? trim($tableMap['key']) : 'id';

        return $rs;
    }
908900
public function getMappedFirstEntitiesByEntityType($entityName)
    {
        $entities = [];
        foreach ($this->data as $data) {
            $entity = $this->createAndReturnNewFirstEntity($data, $entityName);
            if ($entity) {
                $entities[] = $entity;
            }
        }
        return $entities;
    }
1174951
public function withTable(string $tableName) : TableWidgetDefiner
    {
        if (!isset($this->tables[$tableName])) {
            throw InvalidArgumentException::format(
                'Invalid table name supplied to %s: expecting one of (%s), \'%s\' given',
                __METHOD__, Debug::formatValues(array_keys($this->tables)), $tableName
            );
        }

        return new TableWidgetDefiner($this->name, $this->label, $this->authSystem, $this->requiredPermissions, $this->tables[$tableName], $this->callback);
    }
1295192
public function throughJoinTable(string $tableName) : ManyToManyParentIdDefiner
    {
        return new ManyToManyParentIdDefiner($this->callback, $this->mapperLoader, $tableName, $this->bidirectionalRelationProperty,  $this->loadIds);
    }
574904
public function addTable($tableName)
    {
        $this->tables[$tableName] = new TableMap($tableName, $this);

        return $this->tables[$tableName];
    }
489885
public function GetTableColumnNames($tableName) {
        $this->setDbConfigList(array());
        $dbConfig = new \Puzzlout\Framework\Dal\DbStatementConfig(null, \Puzzlout\Framework\Dal\DbExecutionType::COLUMNNAMES, new \Puzzlout\Framework\Dal\DbQueryFilters());
        $dbConfig->setQuery("DESCRIBE `$tableName`;");
        $this->addDbConfigItem($dbConfig);
        return $this->BindParametersAndExecute();
    }