A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.yiiframework.com/doc/api/2.0/yii-db-sqlite-schema below:

Schema, yii\db\sqlite\Schema | API Documentation for Yii 2.0

Schema is the class for retrieving metadata from a SQLite (2/3) database.

Hide inherited methods

Defined in: yii\base\BaseObject::__call()

Calls the named method which is not a class method.

Do not call this method directly as it is a PHP magic method that will be implicitly called when an unknown method is being invoked.

Source code

                public function __call($name, $params)
{
    throw new UnknownMethodException('Calling unknown method: ' . get_class($this) . "::$name()");
}

            

Defined in: yii\base\BaseObject::__construct()

Constructor.

The default implementation does two things:

If this method is overridden in a child class, it is recommended that

public void __construct ( $config = [] ) $config array

Name-value pairs that will be used to initialize the object properties

Source code

                public function __construct($config = [])
{
    if (!empty($config)) {
        Yii::configure($this, $config);
    }
    $this->init();
}

            

Defined in: yii\base\BaseObject::__get()

Returns the value of an object property.

Do not call this method directly as it is a PHP magic method that will be implicitly called when executing $value = $object->property;.

See also __set().

Source code

                public function __get($name)
{
    $getter = 'get' . $name;
    if (method_exists($this, $getter)) {
        return $this->$getter();
    } elseif (method_exists($this, 'set' . $name)) {
        throw new InvalidCallException('Getting write-only property: ' . get_class($this) . '::' . $name);
    }
    throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name);
}

            
public boolean __isset ( $name ) $name string

The property name or the event name

return boolean

Whether the named property is set (not null).

Source code

                public function __isset($name)
{
    $getter = 'get' . $name;
    if (method_exists($this, $getter)) {
        return $this->$getter() !== null;
    }
    return false;
}

            

Defined in: yii\base\BaseObject::__set()

Sets value of an object property.

Do not call this method directly as it is a PHP magic method that will be implicitly called when executing $object->property = $value;.

See also __get().

Source code

                public function __set($name, $value)
{
    $setter = 'set' . $name;
    if (method_exists($this, $setter)) {
        $this->$setter($value);
    } elseif (method_exists($this, 'get' . $name)) {
        throw new InvalidCallException('Setting read-only property: ' . get_class($this) . '::' . $name);
    } else {
        throw new UnknownPropertyException('Setting unknown property: ' . get_class($this) . '::' . $name);
    }
}

            

Defined in: yii\base\BaseObject::__unset()

Sets an object property to null.

Do not call this method directly as it is a PHP magic method that will be implicitly called when executing unset($object->property).

Note that if the property is not defined, this method will do nothing. If the property is read-only, it will throw an exception.

See also https://www.php.net/manual/en/function.unset.php.

Source code

                public function __unset($name)
{
    $setter = 'set' . $name;
    if (method_exists($this, $setter)) {
        $this->$setter(null);
    } elseif (method_exists($this, 'get' . $name)) {
        throw new InvalidCallException('Unsetting read-only property: ' . get_class($this) . '::' . $name);
    }
}

            

Defined in: yii\base\BaseObject::canGetProperty()

Returns a value indicating whether a property can be read.

A property is readable if:

See also canSetProperty().

Source code

                public function canGetProperty($name, $checkVars = true)
{
    return method_exists($this, 'get' . $name) || $checkVars && property_exists($this, $name);
}

            

Defined in: yii\base\BaseObject::canSetProperty()

Returns a value indicating whether a property can be set.

A property is writable if:

See also canGetProperty().

public boolean canSetProperty ( $name, $checkVars true ) $name string

The property name

$checkVars boolean

Whether to treat member variables as properties

return boolean

Whether the property can be written

Source code

                public function canSetProperty($name, $checkVars = true)
{
    return method_exists($this, 'set' . $name) || $checkVars && property_exists($this, $name);
}

            

Deprecated since 2.0.14. On PHP >=5.5, use ::class instead.

Source code

                public static function className()
{
    return get_called_class();
}

            

Source code

                public function convertException(\Exception $e, $rawSql)
{
    if ($e instanceof Exception) {
        return $e;
    }
    $exceptionClass = '\yii\db\Exception';
    foreach ($this->exceptionMap as $error => $class) {
        if (strpos($e->getMessage(), $error) !== false) {
            $exceptionClass = $class;
        }
    }
    $message = $e->getMessage() . "\nThe SQL being executed was: $rawSql";
    $errorInfo = $e instanceof \PDOException ? $e->errorInfo : null;
    return new $exceptionClass($message, $errorInfo, $e->getCode(), $e);
}

            

Defined in: yii\db\Schema::createColumnSchema()

Creates a column schema for the database.

This method may be overridden by child classes to create a DBMS-specific column schema.

Source code

                protected function createColumnSchema()
{
    return Yii::createObject($this->columnSchemaClass);
}

            

Create a column schema builder instance giving the type and value precision.

This method may be overridden by child classes to create a DBMS-specific column schema builder.

Source code

                public function createColumnSchemaBuilder($type, $length = null)
{
    return Yii::createObject(ColumnSchemaBuilder::className(), [$type, $length]);
}

            

Creates a query builder for the MySQL database.

This method may be overridden by child classes to create a DBMS-specific query builder.

Source code

                public function createQueryBuilder()
{
    return Yii::createObject(QueryBuilder::className(), [$this->db]);
}

            

Source code

                public function createSavepoint($name)
{
    $this->db->createCommand("SAVEPOINT $name")->execute();
}

            

Collects the table column metadata.

Source code

                protected function findColumns($table)
{
    $sql = 'PRAGMA table_info(' . $this->quoteSimpleTableName($table->name) . ')';
    $columns = $this->db->createCommand($sql)->queryAll();
    if (empty($columns)) {
        return false;
    }
    foreach ($columns as $info) {
        $column = $this->loadColumnSchema($info);
        $table->columns[$column->name] = $column;
        if ($column->isPrimaryKey) {
            $table->primaryKey[] = $column->name;
        }
    }
    if (count($table->primaryKey) === 1 && !strncasecmp($table->columns[$table->primaryKey[0]]->dbType, 'int', 3)) {
        $table->sequenceName = '';
        $table->columns[$table->primaryKey[0]]->autoIncrement = true;
    }
    return true;
}

            

Collects the foreign key column details for the given table.

Source code

                protected function findConstraints($table)
{
    $sql = 'PRAGMA foreign_key_list(' . $this->quoteSimpleTableName($table->name) . ')';
    $keys = $this->db->createCommand($sql)->queryAll();
    foreach ($keys as $key) {
        $id = (int) $key['id'];
        if (!isset($table->foreignKeys[$id])) {
            $table->foreignKeys[$id] = [$key['table'], $key['from'] => $key['to']];
        } else {
            
            $table->foreignKeys[$id][$key['from']] = $key['to'];
        }
    }
}

            

Defined in: yii\db\Schema::findSchemaNames()

Returns all schema names in the database, including the default one but not system schemas.

This method should be overridden by child classes in order to support this feature because the default implementation simply throws an exception.

Source code

                protected function findSchemaNames()
{
    throw new NotSupportedException(get_class($this) . ' does not support fetching all schema names.');
}

            

Returns all table names in the database.

This method should be overridden by child classes in order to support this feature because the default implementation simply throws an exception.

protected array findTableNames ( $schema '' ) $schema string

The schema of the tables. Defaults to empty string, meaning the current or default schema.

return array

All table names in the database. The names have NO schema name prefix.

throws yii\base\NotSupportedException

if this method is not supported by the DBMS.

Source code

                protected function findTableNames($schema = '')
{
    $sql = "SELECT DISTINCT tbl_name FROM sqlite_master WHERE tbl_name<>'sqlite_sequence' ORDER BY tbl_name";
    return $this->db->createCommand($sql)->queryColumn();
}

            

Returns all unique indexes for the given table.

Each array element is of the following structure:

[
    'IndexName1' => ['col1' [, ...]],
    'IndexName2' => ['col2' [, ...]],
]

Source code

                public function findUniqueIndexes($table)
{
    $sql = 'PRAGMA index_list(' . $this->quoteSimpleTableName($table->name) . ')';
    $indexes = $this->db->createCommand($sql)->queryAll();
    $uniqueIndexes = [];
    foreach ($indexes as $index) {
        $indexName = $index['name'];
        $indexInfo = $this->db->createCommand('PRAGMA index_info(' . $this->quoteValue($index['name']) . ')')->queryAll();
        if ($index['unique']) {
            $uniqueIndexes[$indexName] = [];
            foreach ($indexInfo as $row) {
                $uniqueIndexes[$indexName][] = $row['name'];
            }
        }
    }
    return $uniqueIndexes;
}

            
protected mixed getCacheKey ( $name ) $name string

The table name.

return mixed

The cache key.

Source code

                protected function getCacheKey($name)
{
    return [
        __CLASS__,
        $this->db->dsn,
        $this->db->username,
        $this->getRawTableName($name),
    ];
}

            

Source code

                protected function getCacheTag()
{
    return md5(serialize([
        __CLASS__,
        $this->db->dsn,
        $this->db->username,
    ]));
}

            

Source code

                protected function getColumnPhpType($column)
{
    static $typeMap = [
        
        self::TYPE_TINYINT => 'integer',
        self::TYPE_SMALLINT => 'integer',
        self::TYPE_INTEGER => 'integer',
        self::TYPE_BIGINT => 'integer',
        self::TYPE_BOOLEAN => 'boolean',
        self::TYPE_FLOAT => 'double',
        self::TYPE_DOUBLE => 'double',
        self::TYPE_BINARY => 'resource',
        self::TYPE_JSON => 'array',
    ];
    if (isset($typeMap[$column->type])) {
        if ($column->type === 'bigint') {
            return PHP_INT_SIZE === 8 && !$column->unsigned ? 'integer' : 'string';
        } elseif ($column->type === 'integer') {
            return PHP_INT_SIZE === 4 && $column->unsigned ? 'string' : 'integer';
        }
        return $typeMap[$column->type];
    }
    return 'string';
}

            

Source code

                public function getLastInsertID($sequenceName = '')
{
    if ($this->db->isActive) {
        return $this->db->pdo->lastInsertId($sequenceName === '' ? null : $this->quoteTableName($sequenceName));
    }
    throw new InvalidCallException('DB Connection is not active.');
}

            

Source code

                public function getPdoType($data)
{
    static $typeMap = [
        
        'boolean' => \PDO::PARAM_BOOL,
        'integer' => \PDO::PARAM_INT,
        'string' => \PDO::PARAM_STR,
        'resource' => \PDO::PARAM_LOB,
        'NULL' => \PDO::PARAM_NULL,
    ];
    $type = gettype($data);
    return isset($typeMap[$type]) ? $typeMap[$type] : \PDO::PARAM_STR;
}

            

Source code

                public function getQueryBuilder()
{
    if ($this->_builder === null) {
        $this->_builder = $this->createQueryBuilder();
    }
    return $this->_builder;
}

            

Source code

                public function getRawTableName($name)
{
    if (strpos($name, '{{') !== false) {
        $name = preg_replace('/\\{\\{(.*?)\\}\\}/', '\1', $name);
        return str_replace('%', $this->db->tablePrefix, $name);
    }
    return $name;
}

            
public \yii\db\CheckConstraint[][] getSchemaChecks ( $schema '', $refresh false ) $schema string

The schema of the tables. Defaults to empty string, meaning the current or default schema name.

$refresh boolean

Whether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

return \yii\db\CheckConstraint[][]

Check constraints for all tables in the database. Each array element is an array of yii\db\CheckConstraint or its child classes.

Source code

                public function getSchemaChecks($schema = '', $refresh = false)
{
    return $this->getSchemaMetadata($schema, 'checks', $refresh);
}

            

Source code

                public function getSchemaDefaultValues($schema = '', $refresh = false)
{
    return $this->getSchemaMetadata($schema, 'defaultValues', $refresh);
}

            
public \yii\db\ForeignKeyConstraint[][] getSchemaForeignKeys ( $schema '', $refresh false ) $schema string

The schema of the tables. Defaults to empty string, meaning the current or default schema name.

$refresh boolean

Whether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

return \yii\db\ForeignKeyConstraint[][]

Foreign keys for all tables in the database. Each array element is an array of yii\db\ForeignKeyConstraint or its child classes.

Source code

                public function getSchemaForeignKeys($schema = '', $refresh = false)
{
    return $this->getSchemaMetadata($schema, 'foreignKeys', $refresh);
}

            
public \yii\db\IndexConstraint[][] getSchemaIndexes ( $schema '', $refresh false ) $schema string

The schema of the tables. Defaults to empty string, meaning the current or default schema name.

$refresh boolean

Whether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

return \yii\db\IndexConstraint[][]

Indexes for all tables in the database. Each array element is an array of yii\db\IndexConstraint or its child classes.

Source code

                public function getSchemaIndexes($schema = '', $refresh = false)
{
    return $this->getSchemaMetadata($schema, 'indexes', $refresh);
}

            
public string[] getSchemaNames ( $refresh false ) $refresh boolean

Whether to fetch the latest available schema names. If this is false, schema names fetched previously (if available) will be returned.

return string[]

All schema names in the database, except system schemas.

Source code

                public function getSchemaNames($refresh = false)
{
    if ($this->_schemaNames === null || $refresh) {
        $this->_schemaNames = $this->findSchemaNames();
    }
    return $this->_schemaNames;
}

            
public yii\db\Constraint[] getSchemaPrimaryKeys ( $schema '', $refresh false ) $schema string

The schema of the tables. Defaults to empty string, meaning the current or default schema name.

$refresh boolean

Whether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

return yii\db\Constraint[]

Primary keys for all tables in the database. Each array element is an instance of yii\db\Constraint or its child class.

Source code

                public function getSchemaPrimaryKeys($schema = '', $refresh = false)
{
    return $this->getSchemaMetadata($schema, 'primaryKey', $refresh);
}

            
public \yii\db\Constraint[][] getSchemaUniques ( $schema '', $refresh false ) $schema string

The schema of the tables. Defaults to empty string, meaning the current or default schema name.

$refresh boolean

Whether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

return \yii\db\Constraint[][]

Unique constraints for all tables in the database. Each array element is an array of yii\db\Constraint or its child classes.

Source code

                public function getSchemaUniques($schema = '', $refresh = false)
{
    return $this->getSchemaMetadata($schema, 'uniques', $refresh);
}

            

Source code

                public function getServerVersion()
{
    if ($this->_serverVersion === null) {
        $this->_serverVersion = $this->db->getSlavePdo(true)->getAttribute(\PDO::ATTR_SERVER_VERSION);
    }
    return $this->_serverVersion;
}

            

Source code

                public function getTableChecks($name, $refresh = false)
{
    return $this->getTableMetadata($name, 'checks', $refresh);
}

            

Source code

                public function getTableDefaultValues($name, $refresh = false)
{
    return $this->getTableMetadata($name, 'defaultValues', $refresh);
}

            

Source code

                public function getTableForeignKeys($name, $refresh = false)
{
    return $this->getTableMetadata($name, 'foreignKeys', $refresh);
}

            

Source code

                public function getTableIndexes($name, $refresh = false)
{
    return $this->getTableMetadata($name, 'indexes', $refresh);
}

            

Source code

                protected function getTableNameParts($name)
{
    return explode('.', $name);
}

            
public string[] getTableNames ( $schema '', $refresh false ) $schema string

The schema of the tables. Defaults to empty string, meaning the current or default schema name. If not empty, the returned table names will be prefixed with the schema name.

$refresh boolean

Whether to fetch the latest available table names. If this is false, table names fetched previously (if available) will be returned.

return string[]

All table names in the database.

Source code

                public function getTableNames($schema = '', $refresh = false)
{
    if (!isset($this->_tableNames[$schema]) || $refresh) {
        $this->_tableNames[$schema] = $this->findTableNames($schema);
    }
    return $this->_tableNames[$schema];
}

            

Source code

                public function getTablePrimaryKey($name, $refresh = false)
{
    return $this->getTableMetadata($name, 'primaryKey', $refresh);
}

            

Source code

                public function getTableSchema($name, $refresh = false)
{
    return $this->getTableMetadata($name, 'schema', $refresh);
}

            
public yii\db\TableSchema[] getTableSchemas ( $schema '', $refresh false ) $schema string

The schema of the tables. Defaults to empty string, meaning the current or default schema name.

$refresh boolean

Whether to fetch the latest available table schemas. If this is false, cached data may be returned if available.

return yii\db\TableSchema[]

The metadata for all tables in the database. Each array element is an instance of yii\db\TableSchema or its child class.

Source code

                public function getTableSchemas($schema = '', $refresh = false)
{
    return $this->getSchemaMetadata($schema, 'schema', $refresh);
}

            

Source code

                public function getTableUniques($name, $refresh = false)
{
    return $this->getTableMetadata($name, 'uniques', $refresh);
}

            

Defined in: yii\base\BaseObject::hasMethod()

Returns a value indicating whether a method is defined.

The default implementation is a call to php function method_exists(). You may override this method when you implemented the php magic method __call().

Source code

                public function hasMethod($name)
{
    return method_exists($this, $name);
}

            

Defined in: yii\base\BaseObject::hasProperty()

Returns a value indicating whether a property is defined.

A property is defined if:

See also:

public boolean hasProperty ( $name, $checkVars true ) $name string

The property name

$checkVars boolean

Whether to treat member variables as properties

return boolean

Whether the property is defined

Source code

                public function hasProperty($name, $checkVars = true)
{
    return $this->canGetProperty($name, $checkVars) || $this->canSetProperty($name, false);
}

            

Defined in: yii\base\BaseObject::init()

Initializes the object.

This method is invoked at the end of the constructor after the object is initialized with the given configuration.

Source code

                public function init()
{
}

            
public array|false insert ( $table, $columns ) $table string

The table that new rows will be inserted into.

$columns array

The column data (name => value) to be inserted into the table.

return array|false

Primary key values or false if the command fails

Source code

                public function insert($table, $columns)
{
    $command = $this->db->createCommand()->insert($table, $columns);
    if (!$command->execute()) {
        return false;
    }
    $tableSchema = $this->getTableSchema($table);
    $result = [];
    foreach ($tableSchema->primaryKey as $name) {
        if ($tableSchema->columns[$name]->autoIncrement) {
            $result[$name] = $this->getLastInsertID($tableSchema->sequenceName);
            break;
        }
        $result[$name] = isset($columns[$name]) ? $columns[$name] : $tableSchema->columns[$name]->defaultValue;
    }
    return $result;
}

            

Source code

                public function isReadQuery($sql)
{
    $pattern = '/^\s*(SELECT|SHOW|DESCRIBE)\b/i';
    return preg_match($pattern, $sql) > 0;
}

            

Loads the column information into a yii\db\ColumnSchema object.

Source code

                protected function loadColumnSchema($info)
{
    $column = $this->createColumnSchema();
    $column->name = $info['name'];
    $column->allowNull = !$info['notnull'];
    $column->isPrimaryKey = $info['pk'] != 0;
    $column->dbType = strtolower($info['type']);
    $column->unsigned = strpos($column->dbType, 'unsigned') !== false;
    $column->type = self::TYPE_STRING;
    if (preg_match('/^(\w+)(?:\(([^\)]+)\))?/', $column->dbType, $matches)) {
        $type = strtolower($matches[1]);
        if (isset($this->typeMap[$type])) {
            $column->type = $this->typeMap[$type];
        }
        if (!empty($matches[2])) {
            $values = explode(',', $matches[2]);
            $column->size = $column->precision = (int) $values[0];
            if (isset($values[1])) {
                $column->scale = (int) $values[1];
            }
            if ($column->size === 1 && ($type === 'tinyint' || $type === 'bit')) {
                $column->type = 'boolean';
            } elseif ($type === 'bit') {
                if ($column->size > 32) {
                    $column->type = 'bigint';
                } elseif ($column->size === 32) {
                    $column->type = 'integer';
                }
            }
        }
    }
    $column->phpType = $this->getColumnPhpType($column);
    if (!$column->isPrimaryKey) {
        if ($info['dflt_value'] === 'null' || $info['dflt_value'] === '' || $info['dflt_value'] === null) {
            $column->defaultValue = null;
        } elseif ($column->type === 'timestamp' && $info['dflt_value'] === 'CURRENT_TIMESTAMP') {
            $column->defaultValue = new Expression('CURRENT_TIMESTAMP');
        } else {
            $value = trim($info['dflt_value'], "'\"");
            $column->defaultValue = $column->phpTypecast($value);
        }
    }
    return $column;
}

            

Source code

                protected function loadTableChecks($tableName)
{
    $sql = $this->db->createCommand('SELECT `sql` FROM `sqlite_master` WHERE name = :tableName', [
        ':tableName' => $tableName,
    ])->queryScalar();
    
    $code = (new SqlTokenizer($sql))->tokenize();
    $pattern = (new SqlTokenizer('any CREATE any TABLE any()'))->tokenize();
    if (!$code[0]->matches($pattern, 0, $firstMatchIndex, $lastMatchIndex)) {
        return [];
    }
    $createTableToken = $code[0][$lastMatchIndex - 1];
    $result = [];
    $offset = 0;
    while (true) {
        $pattern = (new SqlTokenizer('any CHECK()'))->tokenize();
        if (!$createTableToken->matches($pattern, $offset, $firstMatchIndex, $offset)) {
            break;
        }
        $checkSql = $createTableToken[$offset - 1]->getSql();
        $name = null;
        $pattern = (new SqlTokenizer('CONSTRAINT any'))->tokenize();
        if (isset($createTableToken[$firstMatchIndex - 2]) && $createTableToken->matches($pattern, $firstMatchIndex - 2)) {
            $name = $createTableToken[$firstMatchIndex - 1]->content;
        }
        $result[] = new CheckConstraint([
            'name' => $name,
            'expression' => $checkSql,
        ]);
    }
    return $result;
}

            

Source code

                protected function loadTableDefaultValues($tableName)
{
    throw new NotSupportedException('SQLite does not support default value constraints.');
}

            

Source code

                protected function loadTableForeignKeys($tableName)
{
    $foreignKeys = $this->db->createCommand('PRAGMA FOREIGN_KEY_LIST (' . $this->quoteValue($tableName) . ')')->queryAll();
    $foreignKeys = $this->normalizePdoRowKeyCase($foreignKeys, true);
    $foreignKeys = ArrayHelper::index($foreignKeys, null, 'table');
    ArrayHelper::multisort($foreignKeys, 'seq', SORT_ASC, SORT_NUMERIC);
    $result = [];
    foreach ($foreignKeys as $table => $foreignKey) {
        $result[] = new ForeignKeyConstraint([
            'columnNames' => ArrayHelper::getColumn($foreignKey, 'from'),
            'foreignTableName' => $table,
            'foreignColumnNames' => ArrayHelper::getColumn($foreignKey, 'to'),
            'onDelete' => isset($foreignKey[0]['on_delete']) ? $foreignKey[0]['on_delete'] : null,
            'onUpdate' => isset($foreignKey[0]['on_update']) ? $foreignKey[0]['on_update'] : null,
        ]);
    }
    return $result;
}

            

Source code

                protected function loadTableIndexes($tableName)
{
    return $this->loadTableConstraints($tableName, 'indexes');
}

            

Source code

                protected function loadTablePrimaryKey($tableName)
{
    return $this->loadTableConstraints($tableName, 'primaryKey');
}

            

Loads the metadata for the specified table.

Source code

                protected function loadTableSchema($name)
{
    $table = new TableSchema();
    $table->name = $name;
    $table->fullName = $name;
    if ($this->findColumns($table)) {
        $this->findConstraints($table);
        return $table;
    }
    return null;
}

            

Source code

                protected function loadTableUniques($tableName)
{
    return $this->loadTableConstraints($tableName, 'uniques');
}

            

Source code

                protected function normalizePdoRowKeyCase(array $row, $multiple)
{
    if ($this->db->getSlavePdo(true)->getAttribute(\PDO::ATTR_CASE) !== \PDO::CASE_UPPER) {
        return $row;
    }
    if ($multiple) {
        return array_map(function (array $row) {
            return array_change_key_case($row, CASE_LOWER);
        }, $row);
    }
    return array_change_key_case($row, CASE_LOWER);
}

            

Defined in: yii\db\Schema::quoteColumnName()

Quotes a column name for use in a query.

If the column name contains prefix, the prefix will also be properly quoted. If the column name is already quoted or contains '(', '[[' or '{{', then this method will do nothing.

See also quoteSimpleColumnName().

Source code

                public function quoteColumnName($name)
{
    if (strpos($name, '(') !== false || strpos($name, '[[') !== false) {
        return $name;
    }
    if (($pos = strrpos($name, '.')) !== false) {
        $prefix = $this->quoteTableName(substr($name, 0, $pos)) . '.';
        $name = substr($name, $pos + 1);
    } else {
        $prefix = '';
    }
    if (strpos($name, '{{') !== false) {
        return $name;
    }
    return $prefix . $this->quoteSimpleColumnName($name);
}

            

Defined in: yii\db\Schema::quoteSimpleColumnName()

Quotes a simple column name for use in a query.

A simple column name should contain the column name only without any prefix. If the column name is already quoted or is the asterisk character '*', this method will do nothing.

Source code

                public function quoteSimpleColumnName($name)
{
    if (is_string($this->columnQuoteCharacter)) {
        $startingCharacter = $endingCharacter = $this->columnQuoteCharacter;
    } else {
        list($startingCharacter, $endingCharacter) = $this->columnQuoteCharacter;
    }
    return $name === '*' || strpos($name, $startingCharacter) !== false ? $name : $startingCharacter . $name . $endingCharacter;
}

            

Defined in: yii\db\Schema::quoteSimpleTableName()

Quotes a simple table name for use in a query.

A simple table name should contain the table name only without any schema prefix. If the table name is already quoted, this method will do nothing.

Source code

                public function quoteSimpleTableName($name)
{
    if (is_string($this->tableQuoteCharacter)) {
        $startingCharacter = $endingCharacter = $this->tableQuoteCharacter;
    } else {
        list($startingCharacter, $endingCharacter) = $this->tableQuoteCharacter;
    }
    return strpos($name, $startingCharacter) !== false ? $name : $startingCharacter . $name . $endingCharacter;
}

            

Defined in: yii\db\Schema::quoteTableName()

Quotes a table name for use in a query.

If the table name contains schema prefix, the prefix will also be properly quoted. If the table name is already quoted or contains '(' or '{{', then this method will do nothing.

See also quoteSimpleTableName().

Source code

                public function quoteTableName($name)
{
    if (strncmp($name, '(', 1) === 0 && strpos($name, ')') === strlen($name) - 1) {
        return $name;
    }
    if (strpos($name, '{{') !== false) {
        return $name;
    }
    if (strpos($name, '.') === false) {
        return $this->quoteSimpleTableName($name);
    }
    $parts = $this->getTableNameParts($name);
    foreach ($parts as $i => $part) {
        $parts[$i] = $this->quoteSimpleTableName($part);
    }
    return implode('.', $parts);
}

            

Source code

                public function quoteValue($str)
{
    if (!is_string($str)) {
        return $str;
    }
    if (mb_stripos((string)$this->db->dsn, 'odbc:') === false && ($value = $this->db->getSlavePdo(true)->quote($str)) !== false) {
        return $value;
    }
    
    return "'" . addcslashes(str_replace("'", "''", $str), "\000\n\r\\\032") . "'";
}

            

Defined in: yii\db\Schema::refresh()

Refreshes the schema.

This method cleans up all cached table schemas so that they can be re-created later to reflect the database schema change.

Source code

                public function refresh()
{
    
    $cache = is_string($this->db->schemaCache) ? Yii::$app->get($this->db->schemaCache, false) : $this->db->schemaCache;
    if ($this->db->enableSchemaCache && $cache instanceof CacheInterface) {
        TagDependency::invalidate($cache, $this->getCacheTag());
    }
    $this->_tableNames = [];
    $this->_tableMetadata = [];
}

            

Defined in: yii\db\Schema::refreshTableSchema()

Refreshes the particular table schema.

This method cleans up cached table schema so that it can be re-created later to reflect the database schema change.

Source code

                public function refreshTableSchema($name)
{
    $rawName = $this->getRawTableName($name);
    unset($this->_tableMetadata[$rawName]);
    $this->_tableNames = [];
    
    $cache = is_string($this->db->schemaCache) ? Yii::$app->get($this->db->schemaCache, false) : $this->db->schemaCache;
    if ($this->db->enableSchemaCache && $cache instanceof CacheInterface) {
        $cache->delete($this->getCacheKey($rawName));
    }
}

            

Source code

                public function releaseSavepoint($name)
{
    $this->db->createCommand("RELEASE SAVEPOINT $name")->execute();
}

            

Source code

                protected function resolveTableName($name)
{
    throw new NotSupportedException(get_class($this) . ' does not support resolving table names.');
}

            

Source code

                public function rollBackSavepoint($name)
{
    $this->db->createCommand("ROLLBACK TO SAVEPOINT $name")->execute();
}

            

Source code

                public function setTransactionIsolationLevel($level)
{
    switch ($level) {
        case Transaction::SERIALIZABLE:
            $this->db->createCommand('PRAGMA read_uncommitted = False;')->execute();
            break;
        case Transaction::READ_UNCOMMITTED:
            $this->db->createCommand('PRAGMA read_uncommitted = True;')->execute();
            break;
        default:
            throw new NotSupportedException(get_class($this) . ' only supports transaction isolation levels READ UNCOMMITTED and SERIALIZABLE.');
    }
}

            

Source code

                public function supportsSavepoint()
{
    return $this->db->enableSavepoint;
}

            

Defined in: yii\db\Schema::unquoteSimpleColumnName()

Unquotes a simple column name.

A simple column name should contain the column name only without any prefix. If the column name is not quoted or is the asterisk character '*', this method will do nothing.

Source code

                public function unquoteSimpleColumnName($name)
{
    if (is_string($this->columnQuoteCharacter)) {
        $startingCharacter = $this->columnQuoteCharacter;
    } else {
        $startingCharacter = $this->columnQuoteCharacter[0];
    }
    return strpos($name, $startingCharacter) === false ? $name : substr($name, 1, -1);
}

            

Defined in: yii\db\Schema::unquoteSimpleTableName()

Unquotes a simple table name.

A simple table name should contain the table name only without any schema prefix. If the table name is not quoted, this method will do nothing.

Source code

                public function unquoteSimpleTableName($name)
{
    if (is_string($this->tableQuoteCharacter)) {
        $startingCharacter = $this->tableQuoteCharacter;
    } else {
        $startingCharacter = $this->tableQuoteCharacter[0];
    }
    return strpos($name, $startingCharacter) === false ? $name : substr($name, 1, -1);
}

            

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4