Preparing method of creating table

Checks if the table exists and than if one don't creates the new table

@param string $tableName
@param string $tableConfig
@return mixed
@throws RuntimeException
@throws Exception
182136
public function createTable($tableName, $tableConfig = null)
    {
        if ($this->hasTable($tableName)) {
            throw new RuntimeException("Table with name {$tableName} is exist. Use rewriteTable()");
        }

        return $this->create($tableName, $tableConfig);
    }
1220528
public function tableName($tableName = null)
    {
        if ($tableName === null)
        {
            return $this->_tableName;
        }
        $this->_tableName = $tableName;

        return $this;
    }
1041594
public function tableExists($tableName, $connectionName = 'default')
    {
        try {
            $db = ConnectionManager::get($connectionName);
            $collection = $db->schemaCollection();
            $tables = $collection->listTables();
            if (in_array($tableName, $tables)) {
                return true;
            }
        } catch (PDOException $connectionError) {
            return false;
        }
        return false;
    }
771499
public function getHasConfigurationForField(string $tableName, string $fieldName) : bool
    {
        return isset($this->tca[$tableName]['columns'][$fieldName]);
    }
1181392
public static function tableColumn(Table $table, string $columnName) : ColumnExpr
    {
        if (!$table->hasColumn($columnName)) {
            throw InvalidArgumentException::format(
                'Invalid table column name for table \'%s\': expecting one of (%s), \'%s\' given',
                $table->getName(), Debug::formatValues($table->getColumnNames()), $columnName
            );
        }

        return new ColumnExpr($table->getName(), $table->findColumn($columnName));
    }
203703
public static function create(array $config, $name = 'default')
    {
        // Make sure a connection with same name doesn't exist
        if (array_key_exists($name, static::$connections)) {
            throw new Exception("Database connection {$name} already exists.");
        }

        // Set the class name, with the namespace
        $className = '\Radium\Database\\'. $config['driver'];

        // Connect to the database and return the object
        static::$connections[$name] = new $className($config, $name);
        return static::$connections[$name];
    }
1319739
private function createRunTimeTable(): bool
    {
        $this->setRunTimeTable(new Table('runTime', self::TABLE_SIZE, $this->runTimeStruct));

        return $this->getRunTimeTable()->create();
    }
1037086
protected function autoCreateTable()
    {
        // Without a table creator we cannot create the table
        if (!$this->tableCreator) {
            return false;
        }

        // Do a little test query
        try {

            $this->connection->select("SELECT {$this->quotedIdKey} FROM {$this->quotedTable} LIMIT 1");
            return true;

        } catch (SQLNameNotFoundException $e) { // The only matching Exception in this case
        }

        if ($e->missingType != 'table') {
            throw $e;
        }

        call_user_func($this->tableCreator, $this->connection, $this->table, $this->idKey);

        return true;
    }
239103
public function getColumnDefaultValue($tableName, $columnName) {
        $columns = $this->getTableColumns($tableName);
        foreach ($columns as $column) {
            if ($column['Field'] != $columnName)
                continue;
            return $column['Default'];
        }
        throw new \Exception("Column `$columnName` not found in table `$tableName`!");
    }
884918
protected function tableExists($tableName)
    {
        $rs = $this->getEntityManager()->getConnection()->fetchAll('SHOW TABLE STATUS');

        foreach ($rs as $row) {
            if ($tableName === $row['Name']) {
                return true;
            }
        }

        return false;
    }
429420
public function setTableName($tableName = "")
    {
        if (empty($tableName)) {
            throw new GdgCommonsInvalidArgumentException("Table name must not be null or empty");
        }
        
        if (!is_string($tableName)) {
            throw new GdgCommonsInvalidArgumentException("Table name must be string");
        }
        
        $this->_tableName = $tableName;
    }
716876
public function dropDbTable($tableName)
    {
        $drop = new Ddl\DropTable(trim($tableName));
        $sql  = new Sql($this->getDbAdapter());
        $this->getDbAdapter()->query($sql->getSqlStringForSqlObject($drop), DbAdapter::QUERY_MODE_EXECUTE);
    }
1292616
public function connect( $config )
    {
        if ( $config !== NULL )
        {
            if ( NULL === $config[ 'db_name' ] || '' === $config[ 'db_name' ] )
            {
                throw new DatabaseException( 'Invalid database name.' );
            }

            $this->name = $config[ 'db_name' ];

            try
            {
                $dns = "sqlite:" . $this->name;

                $this->database = new PDO( $dns );

            }
            catch ( Exception $e )
            {
                throw new DatabaseException( $e->getMessage() );
            }
        }
    }
340547
public function set($data, $tableName = null, $tablePrefix = null)
    {
        is_null($tableName) && $tableName = $this->getTableName();
        is_null($tablePrefix) && $tablePrefix = $this->tablePrefix;
        return $this->db($this->getDbConf())->set($tableName, $data, $tablePrefix);
    }
297365
protected function tableExists($tableName)
    {
        $tables = $this->connection->getSchemaManager()->listTables();

        foreach ($tables as $table) {
            if ($table->getName() == $tableName) {
                return true;
            }
        }

        return false;
    }
56312
protected function _addTable(Table $table)
    {
        $namespaceName = $table->getNamespaceName();
        $tableName     = $table->getFullQualifiedName($this->getName());

        if (isset($this->_tables[$tableName])) {
            throw SchemaException::tableAlreadyExists($tableName);
        }

        if ($namespaceName !== null
            && ! $table->isInDefaultNamespace($this->getName())
            && ! $this->hasNamespace($namespaceName)) {
            $this->createNamespace($namespaceName);
        }

        $this->_tables[$tableName] = $table;
        $table->setSchemaConfig($this->_schemaConfig);
    }
1321993
protected static function checkColumn($tableName, $columnName, $con=NULL)
    {
        $connection = self::checkConnection($con);

            $result = $connection->prepare("SELECT {$columnName} FROM {$tableName}");
            $result->execute();
            if (! $result->columnCount())
            {
                throw new ColumnNotExistExeption();
            }
            return $columnName;
    }