PHP 클래스 yii\db\Schema

Schema represents the database schema information that is DBMS specific.
부터: 2.0
저자: Qiang Xue ([email protected])
상속: extends yii\base\Object
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$columnSchemaClass column schema class
$db the database connection
$defaultSchema the default schema name used for the current session.
$exceptionMap map of DB errors and corresponding exceptions If left part is found in DB error message exception class from the right part is used.

공개 메소드들

메소드 설명
convertException ( Exception $e, string $rawSql ) : Exception Converts a DB exception to a more concrete one if possible.
createColumnSchemaBuilder ( string $type, integer | string | array $length = null ) : ColumnSchemaBuilder Create a column schema builder instance giving the type and value precision.
createQueryBuilder ( ) : QueryBuilder Creates a query builder for the database.
createSavepoint ( string $name ) Creates a new savepoint.
findUniqueIndexes ( yii\db\TableSchema $table ) : array Returns all unique indexes for the given table.
getLastInsertID ( string $sequenceName = '' ) : string Returns the ID of the last inserted row or sequence value.
getPdoType ( mixed $data ) : integer Determines the PDO type for the given PHP data value.
getQueryBuilder ( ) : QueryBuilder
getRawTableName ( string $name ) : string Returns the actual name of a given table name.
getSchemaNames ( boolean $refresh = false ) : string[] Returns all schema names in the database, except system schemas.
getTableNames ( string $schema = '', boolean $refresh = false ) : string[] Returns all table names in the database.
getTableSchema ( string $name, boolean $refresh = false ) : null | yii\db\TableSchema Obtains the metadata for the named table.
getTableSchemas ( string $schema = '', boolean $refresh = false ) : yii\db\TableSchema[] Returns the metadata for all tables in the database.
insert ( string $table, array $columns ) : array | false Executes the INSERT command, returning primary key values.
isReadQuery ( string $sql ) : boolean Returns a value indicating whether a SQL statement is for read purpose.
quoteColumnName ( string $name ) : string Quotes a column name for use in a query.
quoteSimpleColumnName ( string $name ) : string Quotes a simple column name for use in a query.
quoteSimpleTableName ( string $name ) : string Quotes a simple table name for use in a query.
quoteTableName ( string $name ) : string Quotes a table name for use in a query.
quoteValue ( string $str ) : string Quotes a string value for use in a query.
refresh ( ) Refreshes the schema.
refreshTableSchema ( string $name ) Refreshes the particular table schema.
releaseSavepoint ( string $name ) Releases an existing savepoint.
rollBackSavepoint ( string $name ) Rolls back to a previously created savepoint.
setTransactionIsolationLevel ( string $level ) Sets the isolation level of the current transaction.
supportsSavepoint ( ) : boolean

보호된 메소드들

메소드 설명
createColumnSchema ( ) : ColumnSchema
findSchemaNames ( ) : array Returns all schema names in the database, including the default one but not system schemas.
findTableNames ( string $schema = '' ) : array Returns all table names in the database.
getCacheKey ( string $name ) : mixed Returns the cache key for the specified table name.
getCacheTag ( ) : string Returns the cache tag name.
getColumnPhpType ( ColumnSchema $column ) : string Extracts the PHP type from abstract DB type.
loadTableSchema ( string $name ) : null | yii\db\TableSchema Loads the metadata for the specified table.

메소드 상세

convertException() 공개 메소드

Converts a DB exception to a more concrete one if possible.
public convertException ( Exception $e, string $rawSql ) : Exception
$e Exception
$rawSql string SQL that produced exception
리턴 Exception

createColumnSchema() 보호된 메소드

protected createColumnSchema ( ) : ColumnSchema
리턴 ColumnSchema

createColumnSchemaBuilder() 공개 메소드

This method may be overridden by child classes to create a DBMS-specific column schema builder.
부터: 2.0.6
public createColumnSchemaBuilder ( string $type, integer | string | array $length = null ) : ColumnSchemaBuilder
$type string type of the column. See [[ColumnSchemaBuilder::$type]].
$length integer | string | array length or precision of the column. See [[ColumnSchemaBuilder::$length]].
리턴 ColumnSchemaBuilder column schema builder instance

createQueryBuilder() 공개 메소드

This method may be overridden by child classes to create a DBMS-specific query builder.
public createQueryBuilder ( ) : QueryBuilder
리턴 QueryBuilder query builder instance

createSavepoint() 공개 메소드

Creates a new savepoint.
public createSavepoint ( string $name )
$name string the savepoint name

findSchemaNames() 보호된 메소드

This method should be overridden by child classes in order to support this feature because the default implementation simply throws an exception.
부터: 2.0.4
protected findSchemaNames ( ) : array
리턴 array all schema names in the database, except system schemas

findTableNames() 보호된 메소드

This method should be overridden by child classes in order to support this feature because the default implementation simply throws an exception.
protected findTableNames ( string $schema = '' ) : array
$schema string the schema of the tables. Defaults to empty string, meaning the current or default schema.
리턴 array all table names in the database. The names have NO schema name prefix.

findUniqueIndexes() 공개 메소드

Each array element is of the following structure: php [ 'IndexName1' => ['col1' [, ...]], 'IndexName2' => ['col2' [, ...]], ] This method should be overridden by child classes in order to support this feature because the default implementation simply throws an exception
public findUniqueIndexes ( yii\db\TableSchema $table ) : array
$table yii\db\TableSchema the table metadata
리턴 array all unique indexes for the given table.

getCacheKey() 보호된 메소드

Returns the cache key for the specified table name.
protected getCacheKey ( string $name ) : mixed
$name string the table name
리턴 mixed the cache key

getCacheTag() 보호된 메소드

This allows Schema::refresh to invalidate all cached table schemas.
protected getCacheTag ( ) : string
리턴 string the cache tag name

getColumnPhpType() 보호된 메소드

Extracts the PHP type from abstract DB type.
protected getColumnPhpType ( ColumnSchema $column ) : string
$column ColumnSchema the column schema information
리턴 string PHP type name

getLastInsertID() 공개 메소드

Returns the ID of the last inserted row or sequence value.
또한 보기: http://www.php.net/manual/en/function.PDO-lastInsertId.php
public getLastInsertID ( string $sequenceName = '' ) : string
$sequenceName string name of the sequence object (required by some DBMS)
리턴 string the row ID of the last row inserted, or the last value retrieved from the sequence object

getPdoType() 공개 메소드

Determines the PDO type for the given PHP data value.
또한 보기: http://www.php.net/manual/en/pdo.constants.php
public getPdoType ( mixed $data ) : integer
$data mixed the data whose PDO type is to be determined
리턴 integer the PDO type

getQueryBuilder() 공개 메소드

public getQueryBuilder ( ) : QueryBuilder
리턴 QueryBuilder the query builder for this connection.

getRawTableName() 공개 메소드

This method will strip off curly brackets from the given table name and replace the percentage character '%' with [[Connection::tablePrefix]].
public getRawTableName ( string $name ) : string
$name string the table name to be converted
리턴 string the real name of the given table name

getSchemaNames() 공개 메소드

Returns all schema names in the database, except system schemas.
부터: 2.0.4
public getSchemaNames ( boolean $refresh = false ) : string[]
$refresh boolean whether to fetch the latest available schema names. If this is false, schema names fetched previously (if available) will be returned.
리턴 string[] all schema names in the database, except system schemas.

getTableNames() 공개 메소드

Returns all table names in the database.
public getTableNames ( string $schema = '', boolean $refresh = false ) : string[]
$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.
리턴 string[] all table names in the database.

getTableSchema() 공개 메소드

Obtains the metadata for the named table.
public getTableSchema ( string $name, boolean $refresh = false ) : null | yii\db\TableSchema
$name string table name. The table name may contain schema name if any. Do not quote the table name.
$refresh boolean whether to reload the table schema even if it is found in the cache.
리턴 null | yii\db\TableSchema table metadata. Null if the named table does not exist.

getTableSchemas() 공개 메소드

Returns the metadata for all tables in the database.
public getTableSchemas ( string $schema = '', boolean $refresh = false ) : yii\db\TableSchema[]
$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.
리턴 yii\db\TableSchema[] the metadata for all tables in the database. Each array element is an instance of [[TableSchema]] or its child class.

insert() 공개 메소드

Executes the INSERT command, returning primary key values.
부터: 2.0.4
public insert ( string $table, array $columns ) : array | false
$table string the table that new rows will be inserted into.
$columns array the column data (name => value) to be inserted into the table.
리턴 array | false primary key values or false if the command fails

isReadQuery() 공개 메소드

Returns a value indicating whether a SQL statement is for read purpose.
public isReadQuery ( string $sql ) : boolean
$sql string the SQL statement
리턴 boolean whether a SQL statement is for read purpose.

loadTableSchema() 추상적인 보호된 메소드

Loads the metadata for the specified table.
abstract protected loadTableSchema ( string $name ) : null | yii\db\TableSchema
$name string table name
리턴 null | yii\db\TableSchema DBMS-dependent table metadata, null if the table does not exist.

quoteColumnName() 공개 메소드

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.
또한 보기: quoteSimpleColumnName()
public quoteColumnName ( string $name ) : string
$name string column name
리턴 string the properly quoted column name

quoteSimpleColumnName() 공개 메소드

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.
public quoteSimpleColumnName ( string $name ) : string
$name string column name
리턴 string the properly quoted column name

quoteSimpleTableName() 공개 메소드

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.
public quoteSimpleTableName ( string $name ) : string
$name string table name
리턴 string the properly quoted table name

quoteTableName() 공개 메소드

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.
또한 보기: quoteSimpleTableName()
public quoteTableName ( string $name ) : string
$name string table name
리턴 string the properly quoted table name

quoteValue() 공개 메소드

Note that if the parameter is not a string, it will be returned without change.
또한 보기: http://www.php.net/manual/en/function.PDO-quote.php
public quoteValue ( string $str ) : string
$str string string to be quoted
리턴 string the properly quoted string

refresh() 공개 메소드

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

refreshTableSchema() 공개 메소드

This method cleans up cached table schema so that it can be re-created later to reflect the database schema change.
부터: 2.0.6
public refreshTableSchema ( string $name )
$name string table name.

releaseSavepoint() 공개 메소드

Releases an existing savepoint.
public releaseSavepoint ( string $name )
$name string the savepoint name

rollBackSavepoint() 공개 메소드

Rolls back to a previously created savepoint.
public rollBackSavepoint ( string $name )
$name string the savepoint name

setTransactionIsolationLevel() 공개 메소드

Sets the isolation level of the current transaction.
또한 보기: http://en.wikipedia.org/wiki/Isolation_%28database_systems%29#Isolation_levels
public setTransactionIsolationLevel ( string $level )
$level string The transaction isolation level to use for this transaction. This can be one of [[Transaction::READ_UNCOMMITTED]], [[Transaction::READ_COMMITTED]], [[Transaction::REPEATABLE_READ]] and [[Transaction::SERIALIZABLE]] but also a string containing DBMS specific syntax to be used after `SET TRANSACTION ISOLATION LEVEL`.

supportsSavepoint() 공개 메소드

public supportsSavepoint ( ) : boolean
리턴 boolean whether this DBMS supports [savepoint](http://en.wikipedia.org/wiki/Savepoint).

프로퍼티 상세

$columnSchemaClass 공개적으로 프로퍼티

column schema class
부터: 2.0.11
public $columnSchemaClass

$db 공개적으로 프로퍼티

the database connection
public $db

$defaultSchema 공개적으로 프로퍼티

the default schema name used for the current session.
public $defaultSchema

$exceptionMap 공개적으로 프로퍼티

map of DB errors and corresponding exceptions If left part is found in DB error message exception class from the right part is used.
public $exceptionMap