HumHub Documentation (unofficial)

Schema extends Schema
in package
implements ConstraintFinderInterface uses ConstraintFinderTrait

Schema is the class for retrieving metadata from a CUBRID database (version 9.3.x and higher).

Tags
author

Carsten Brandt mail@cebe.cc

since
2.0

Table of Contents

Interfaces

ConstraintFinderInterface
ConstraintFinderInterface defines methods for getting a table constraint information.

Constants

SCHEMA_CACHE_VERSION  = 1
Schema cache version, to detect incompatibilities in cached values when the data format of the cache changes.
TYPE_BIGINT  = 'bigint'
TYPE_BIGPK  = 'bigpk'
TYPE_BINARY  = 'binary'
TYPE_BOOLEAN  = 'boolean'
TYPE_CHAR  = 'char'
TYPE_DATE  = 'date'
TYPE_DATETIME  = 'datetime'
TYPE_DECIMAL  = 'decimal'
TYPE_DOUBLE  = 'double'
TYPE_FLOAT  = 'float'
TYPE_INTEGER  = 'integer'
TYPE_JSON  = 'json'
TYPE_MONEY  = 'money'
TYPE_PK  = 'pk'
TYPE_SMALLINT  = 'smallint'
TYPE_STRING  = 'string'
TYPE_TEXT  = 'text'
TYPE_TIME  = 'time'
TYPE_TIMESTAMP  = 'timestamp'
TYPE_TINYINT  = 'tinyint'
TYPE_UBIGPK  = 'ubigpk'
TYPE_UPK  = 'upk'

Properties

$columnSchemaClass  : string|array<string|int, mixed>
$db  : Connection
$defaultSchema  : string
$exceptionMap  : array<string|int, mixed>
$lastInsertID  : string
$queryBuilder  : QueryBuilder
$schemaNames  : array<string|int, string>
$serverVersion  : string
$tableNames  : array<string|int, string>
$tableSchemas  : array<string|int, TableSchema>
$transactionIsolationLevel  : string
$typeMap  : array<string|int, mixed>
$columnQuoteCharacter  : string|array<string|int, string>
$tableQuoteCharacter  : string|array<string|int, string>
$_builder  : QueryBuilder
$_schemaNames  : array<string|int, mixed>
$_serverVersion  : string
$_tableMetadata  : array<string|int, mixed>
$_tableNames  : array<string|int, mixed>

Methods

__call()  : mixed
Calls the named method which is not a class method.
__construct()  : mixed
Constructor.
__get()  : mixed
Returns the value of an object property.
__isset()  : bool
Checks if a property is set, i.e. defined and not null.
__set()  : mixed
Sets value of an object property.
__unset()  : mixed
Sets an object property to null.
canGetProperty()  : bool
Returns a value indicating whether a property can be read.
canSetProperty()  : bool
Returns a value indicating whether a property can be set.
className()  : string
Returns the fully qualified name of this class.
convertException()  : Exception
Converts a DB exception to a more concrete one if possible.
createColumnSchemaBuilder()  : ColumnSchemaBuilder
Create a column schema builder instance giving the type and value precision.
createQueryBuilder()  : QueryBuilder
Creates a query builder for the CUBRID database.
createSavepoint()  : mixed
Creates a new savepoint.
findUniqueIndexes()  : array<string|int, mixed>
Returns all unique indexes for the given table.
getLastInsertID()  : string
Returns the ID of the last inserted row or sequence value.
getPdoType()  : int
Determines the PDO type for the given PHP data value.
getQueryBuilder()  : QueryBuilder
getRawTableName()  : string
Returns the actual name of a given table name.
getSchemaChecks()  : array<string|int, array<string|int, CheckConstraint>>
Returns check constraints for all tables in the database.
getSchemaDefaultValues()  : array<string|int, DefaultValueConstraint>
Returns default value constraints for all tables in the database.
getSchemaForeignKeys()  : array<string|int, array<string|int, ForeignKeyConstraint>>
Returns foreign keys for all tables in the database.
getSchemaIndexes()  : array<string|int, array<string|int, IndexConstraint>>
Returns indexes for all tables in the database.
getSchemaNames()  : array<string|int, string>
Returns all schema names in the database, except system schemas.
getSchemaPrimaryKeys()  : array<string|int, Constraint>
Returns primary keys for all tables in the database.
getSchemaUniques()  : array<string|int, array<string|int, Constraint>>
Returns unique constraints for all tables in the database.
getServerVersion()  : string
Returns a server version as a string comparable by [[\version_compare()]].
getTableChecks()  : array<string|int, CheckConstraint>
Obtains the check constraints information for the named table.
getTableDefaultValues()  : array<string|int, DefaultValueConstraint>
Obtains the default value constraints information for the named table.
getTableForeignKeys()  : array<string|int, ForeignKeyConstraint>
Obtains the foreign keys information for the named table.
getTableIndexes()  : array<string|int, IndexConstraint>
Obtains the indexes information for the named table.
getTableNames()  : array<string|int, string>
Returns all table names in the database.
getTablePrimaryKey()  : Constraint|null
Obtains the primary key for the named table.
getTableSchema()  : TableSchema|null
Obtains the metadata for the named table.
getTableSchemas()  : array<string|int, TableSchema>
Returns the metadata for all tables in the database.
getTableUniques()  : array<string|int, Constraint>
Obtains the unique constraints information for the named table.
hasMethod()  : bool
Returns a value indicating whether a method is defined.
hasProperty()  : bool
Returns a value indicating whether a property is defined.
init()  : mixed
Initializes the object.
insert()  : array<string|int, mixed>|false
Executes the INSERT command, returning primary key values.
isReadQuery()  : bool
Returns a value indicating whether a SQL statement is for read purpose.
quoteColumnName()  : string
Quotes a column name for use in a query.
quoteSimpleColumnName()  : string
Quotes a simple column name for use in a query.
quoteSimpleTableName()  : string
Quotes a simple table name for use in a query.
quoteTableName()  : string
Quotes a table name for use in a query.
quoteValue()  : string
Quotes a string value for use in a query.
refresh()  : mixed
Refreshes the schema.
refreshTableSchema()  : mixed
Refreshes the particular table schema.
releaseSavepoint()  : mixed
Releases an existing savepoint.
rollBackSavepoint()  : mixed
Rolls back to a previously created savepoint.
setTransactionIsolationLevel()  : mixed
Sets the isolation level of the current transaction.
supportsSavepoint()  : bool
unquoteSimpleColumnName()  : string
Unquotes a simple column name.
unquoteSimpleTableName()  : string
Unquotes a simple table name.
createColumnSchema()  : ColumnSchema
Creates a column schema for the database.
findSchemaNames()  : array<string|int, mixed>
Returns all schema names in the database, including the default one but not system schemas.
findTableNames()  : array<string|int, mixed>
Returns all table names in the database.
getCacheKey()  : mixed
Returns the cache key for the specified table name.
getCacheTag()  : string
Returns the cache tag name.
getColumnPhpType()  : string
Extracts the PHP type from abstract DB type.
getSchemaMetadata()  : array<string|int, mixed>
Returns the metadata of the given type for all tables in the given schema.
getTableMetadata()  : mixed
Returns the metadata of the given type for the given table.
getTableNameParts()  : array<string|int, mixed>
Splits full table name into parts
loadColumnSchema()  : ColumnSchema
Loads the column information into a [[ColumnSchema]] object.
loadTableChecks()  : mixed
{@inheritdoc}
loadTableDefaultValues()  : mixed
{@inheritdoc}
loadTableForeignKeys()  : mixed
{@inheritdoc}
loadTableIndexes()  : mixed
{@inheritdoc}
loadTablePrimaryKey()  : mixed
{@inheritdoc}
loadTableSchema()  : TableSchema|null
Loads the metadata for the specified table.
loadTableUniques()  : mixed
{@inheritdoc}
normalizePdoRowKeyCase()  : array<string|int, mixed>
Changes row's array key case to lower if PDO's one is set to uppercase.
resolveTableName()  : TableSchema
Resolves the table name and schema name (if any).
setTableMetadata()  : mixed
Sets the metadata of the given type for the given table.
loadTableConstraints()  : mixed
Loads multiple types of constraints and returns the specified ones.
loadTableMetadataFromCache()  : mixed
Tries to load and populate table metadata from cache.
saveTableMetadataToCache()  : mixed
Saves table metadata to cache.

Constants

SCHEMA_CACHE_VERSION

Schema cache version, to detect incompatibilities in cached values when the data format of the cache changes.

public mixed SCHEMA_CACHE_VERSION = 1

TYPE_BIGINT

public mixed TYPE_BIGINT = 'bigint'

TYPE_BIGPK

public mixed TYPE_BIGPK = 'bigpk'

TYPE_BINARY

public mixed TYPE_BINARY = 'binary'

TYPE_BOOLEAN

public mixed TYPE_BOOLEAN = 'boolean'

TYPE_CHAR

public mixed TYPE_CHAR = 'char'

TYPE_DATE

public mixed TYPE_DATE = 'date'

TYPE_DATETIME

public mixed TYPE_DATETIME = 'datetime'

TYPE_DECIMAL

public mixed TYPE_DECIMAL = 'decimal'

TYPE_DOUBLE

public mixed TYPE_DOUBLE = 'double'

TYPE_FLOAT

public mixed TYPE_FLOAT = 'float'

TYPE_INTEGER

public mixed TYPE_INTEGER = 'integer'

TYPE_JSON

public mixed TYPE_JSON = 'json'

TYPE_MONEY

public mixed TYPE_MONEY = 'money'

TYPE_PK

public mixed TYPE_PK = 'pk'

TYPE_SMALLINT

public mixed TYPE_SMALLINT = 'smallint'

TYPE_STRING

public mixed TYPE_STRING = 'string'

TYPE_TEXT

public mixed TYPE_TEXT = 'text'

TYPE_TIME

public mixed TYPE_TIME = 'time'

TYPE_TIMESTAMP

public mixed TYPE_TIMESTAMP = 'timestamp'

TYPE_TINYINT

public mixed TYPE_TINYINT = 'tinyint'

TYPE_UBIGPK

public mixed TYPE_UBIGPK = 'ubigpk'

TYPE_UPK

public mixed TYPE_UPK = 'upk'

Properties

$columnSchemaClass

public string|array<string|int, mixed> $columnSchemaClass = 'yii\db\ColumnSchema'

column schema class or class config

Tags
since
2.0.11

$defaultSchema

public string $defaultSchema

the default schema name used for the current session.

$exceptionMap

public array<string|int, mixed> $exceptionMap = ['Operation would have caused one or more unique constraint violations' => 'yii\db\IntegrityException']

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

$lastInsertID read-only

public string $lastInsertID

The row ID of the last row inserted, or the last value retrieved from the sequence object.

$queryBuilder read-only

public QueryBuilder $queryBuilder

The query builder for this connection.

$schemaNames read-only

public array<string|int, string> $schemaNames

All schema names in the database, except system schemas.

$serverVersion read-only

public string $serverVersion

Server version as a string.

$tableNames read-only

public array<string|int, string> $tableNames

All table names in the database.

$tableSchemas read-only

public array<string|int, TableSchema> $tableSchemas

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

$transactionIsolationLevel write-only

public string $transactionIsolationLevel

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.

$typeMap

public array<string|int, mixed> $typeMap = [ // Numeric data types 'short' => self::TYPE_SMALLINT, 'smallint' => self::TYPE_SMALLINT, 'int' => self::TYPE_INTEGER, 'integer' => self::TYPE_INTEGER, 'bigint' => self::TYPE_BIGINT, 'numeric' => self::TYPE_DECIMAL, 'decimal' => self::TYPE_DECIMAL, 'float' => self::TYPE_FLOAT, 'real' => self::TYPE_FLOAT, 'double' => self::TYPE_DOUBLE, 'double precision' => self::TYPE_DOUBLE, 'monetary' => self::TYPE_MONEY, // Date/Time data types 'date' => self::TYPE_DATE, 'time' => self::TYPE_TIME, 'timestamp' => self::TYPE_TIMESTAMP, 'datetime' => self::TYPE_DATETIME, // String data types 'char' => self::TYPE_CHAR, 'varchar' => self::TYPE_STRING, 'char varying' => self::TYPE_STRING, 'nchar' => self::TYPE_CHAR, 'nchar varying' => self::TYPE_STRING, 'string' => self::TYPE_STRING, // BLOB/CLOB data types 'blob' => self::TYPE_BINARY, 'clob' => self::TYPE_BINARY, // Bit string data types 'bit' => self::TYPE_INTEGER, 'bit varying' => self::TYPE_INTEGER, // Collection data types (considered strings for now) 'set' => self::TYPE_STRING, 'multiset' => self::TYPE_STRING, 'list' => self::TYPE_STRING, 'sequence' => self::TYPE_STRING, 'enum' => self::TYPE_STRING, ]

mapping from physical column types (keys) to abstract column types (values) Please refer to CUBRID manual for details on data types.

$columnQuoteCharacter

protected string|array<string|int, string> $columnQuoteCharacter = '"'

character used to quote column names. An array of 2 characters can be used in case starting and ending characters are different.

Tags
since
2.0.14

$tableQuoteCharacter

protected string|array<string|int, string> $tableQuoteCharacter = '"'

character used to quote schema, table, etc. names. An array of 2 characters can be used in case starting and ending characters are different.

$_schemaNames

private array<string|int, mixed> $_schemaNames

list of ALL schema names in the database, except system schemas

$_serverVersion

private string $_serverVersion

server version as a string.

$_tableMetadata

private array<string|int, mixed> $_tableMetadata = []

list of loaded table metadata (table name => metadata type => metadata).

$_tableNames

private array<string|int, mixed> $_tableNames = []

list of ALL table names in the database

Methods

__call()

Calls the named method which is not a class method.

public __call(string $name, array<string|int, mixed> $params) : mixed

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.

Parameters
$name : string

the method name

$params : array<string|int, mixed>

method parameters

Tags
throws
UnknownMethodException

when calling unknown method

Return values
mixed

the method return value

__construct()

Constructor.

public __construct([array<string|int, mixed> $config = [] ]) : mixed

The default implementation does two things:

  • Initializes the object with the given configuration $config.
  • Call [[init()]].

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

  • the last parameter of the constructor is a configuration array, like $config here.
  • call the parent implementation at the end of the constructor.
Parameters
$config : array<string|int, mixed> = []

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

__get()

Returns the value of an object property.

public __get(string $name) : mixed

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

Parameters
$name : string

the property name

Tags
throws
UnknownPropertyException

if the property is not defined

throws
InvalidCallException

if the property is write-only

see
__set()
Return values
mixed

the property value

__isset()

Checks if a property is set, i.e. defined and not null.

public __isset(string $name) : bool

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

Note that if the property is not defined, false will be returned.

Parameters
$name : string

the property name or the event name

Tags
see
https://www.php.net/manual/en/function.isset.php
Return values
bool

whether the named property is set (not null).

__set()

Sets value of an object property.

public __set(string $name, mixed $value) : mixed

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

Parameters
$name : string

the property name or the event name

$value : mixed

the property value

Tags
throws
UnknownPropertyException

if the property is not defined

throws
InvalidCallException

if the property is read-only

see
__get()

__unset()

Sets an object property to null.

public __unset(string $name) : mixed

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.

Parameters
$name : string

the property name

Tags
throws
InvalidCallException

if the property is read only.

see
https://www.php.net/manual/en/function.unset.php

canGetProperty()

Returns a value indicating whether a property can be read.

public canGetProperty(string $name[, bool $checkVars = true ]) : bool

A property is readable if:

  • the class has a getter method associated with the specified name (in this case, property name is case-insensitive);
  • the class has a member variable with the specified name (when $checkVars is true);
Parameters
$name : string

the property name

$checkVars : bool = true

whether to treat member variables as properties

Tags
see
canSetProperty()
Return values
bool

whether the property can be read

canSetProperty()

Returns a value indicating whether a property can be set.

public canSetProperty(string $name[, bool $checkVars = true ]) : bool

A property is writable if:

  • the class has a setter method associated with the specified name (in this case, property name is case-insensitive);
  • the class has a member variable with the specified name (when $checkVars is true);
Parameters
$name : string

the property name

$checkVars : bool = true

whether to treat member variables as properties

Tags
see
canGetProperty()
Return values
bool

whether the property can be written

className()

Returns the fully qualified name of this class.

public static className() : string
Tags
deprecated

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

Return values
string

the fully qualified name of this class.

convertException()

Converts a DB exception to a more concrete one if possible.

public convertException(Exception $e, string $rawSql) : Exception
Parameters
$e : Exception
$rawSql : string

SQL that produced exception

Return values
Exception

createColumnSchemaBuilder()

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

public createColumnSchemaBuilder(mixed $type[, mixed $length = null ]) : ColumnSchemaBuilder
Parameters
$type : mixed

type of the column. See [[ColumnSchemaBuilder::$type]].

$length : mixed = null

length or precision of the column. See [[ColumnSchemaBuilder::$length]].

Return values
ColumnSchemaBuilder

column schema builder instance

createQueryBuilder()

Creates a query builder for the CUBRID database.

public createQueryBuilder() : QueryBuilder
Return values
QueryBuilder

query builder instance

createSavepoint()

Creates a new savepoint.

public createSavepoint(string $name) : mixed
Parameters
$name : string

the savepoint name

findUniqueIndexes()

Returns all unique indexes for the given table.

public findUniqueIndexes(TableSchema $table) : array<string|int, mixed>

Each array element is of the following structure:

[
 '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

Parameters
$table : TableSchema

the table metadata

Tags
throws
NotSupportedException

if this method is called

Return values
array<string|int, mixed>

all unique indexes for the given table.

getLastInsertID()

Returns the ID of the last inserted row or sequence value.

public getLastInsertID([string $sequenceName = '' ]) : string
Parameters
$sequenceName : string = ''

name of the sequence object (required by some DBMS)

Tags
throws
InvalidCallException

if the DB connection is not active

see
https://www.php.net/manual/en/function.PDO-lastInsertId.php
Return values
string

the row ID of the last row inserted, or the last value retrieved from the sequence object

getRawTableName()

Returns the actual name of a given table name.

public getRawTableName(string $name) : string

This method will strip off curly brackets from the given table name and replace the percentage character '%' with [[Connection::tablePrefix]].

Parameters
$name : string

the table name to be converted

Return values
string

the real name of the given table name

getSchemaChecks()

Returns check constraints for all tables in the database.

public getSchemaChecks([string $schema = '' ][, bool $refresh = false ]) : array<string|int, array<string|int, CheckConstraint>>
Parameters
$schema : string = ''

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

$refresh : bool = false

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

Return values
array<string|int, array<string|int, CheckConstraint>>

check constraints for all tables in the database. Each array element is an array of [[CheckConstraint]] or its child classes.

getSchemaDefaultValues()

Returns default value constraints for all tables in the database.

public getSchemaDefaultValues([string $schema = '' ][, bool $refresh = false ]) : array<string|int, DefaultValueConstraint>
Parameters
$schema : string = ''

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

$refresh : bool = false

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

Return values
array<string|int, DefaultValueConstraint>

default value constraints for all tables in the database. Each array element is an array of [[DefaultValueConstraint]] or its child classes.

getSchemaForeignKeys()

Returns foreign keys for all tables in the database.

public getSchemaForeignKeys([string $schema = '' ][, bool $refresh = false ]) : array<string|int, array<string|int, ForeignKeyConstraint>>
Parameters
$schema : string = ''

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

$refresh : bool = false

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

Return values
array<string|int, array<string|int, ForeignKeyConstraint>>

foreign keys for all tables in the database. Each array element is an array of [[ForeignKeyConstraint]] or its child classes.

getSchemaIndexes()

Returns indexes for all tables in the database.

public getSchemaIndexes([string $schema = '' ][, bool $refresh = false ]) : array<string|int, array<string|int, IndexConstraint>>
Parameters
$schema : string = ''

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

$refresh : bool = false

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

Return values
array<string|int, array<string|int, IndexConstraint>>

indexes for all tables in the database. Each array element is an array of [[IndexConstraint]] or its child classes.

getSchemaNames()

Returns all schema names in the database, except system schemas.

public getSchemaNames([bool $refresh = false ]) : array<string|int, string>
Parameters
$refresh : bool = false

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

Tags
since
2.0.4
Return values
array<string|int, string>

all schema names in the database, except system schemas.

getSchemaPrimaryKeys()

Returns primary keys for all tables in the database.

public getSchemaPrimaryKeys([string $schema = '' ][, bool $refresh = false ]) : array<string|int, Constraint>
Parameters
$schema : string = ''

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

$refresh : bool = false

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

Return values
array<string|int, Constraint>

primary keys for all tables in the database. Each array element is an instance of [[Constraint]] or its child class.

getSchemaUniques()

Returns unique constraints for all tables in the database.

public getSchemaUniques([string $schema = '' ][, bool $refresh = false ]) : array<string|int, array<string|int, Constraint>>
Parameters
$schema : string = ''

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

$refresh : bool = false

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

Return values
array<string|int, array<string|int, Constraint>>

unique constraints for all tables in the database. Each array element is an array of [[Constraint]] or its child classes.

getServerVersion()

Returns a server version as a string comparable by [[\version_compare()]].

public getServerVersion() : string
Tags
since
2.0.14
Return values
string

server version as a string.

getTableChecks()

Obtains the check constraints information for the named table.

public getTableChecks(string $name[, bool $refresh = false ]) : array<string|int, CheckConstraint>
Parameters
$name : string

table name. The table name may contain schema name if any. Do not quote the table name.

$refresh : bool = false

whether to reload the information even if it is found in the cache.

Return values
array<string|int, CheckConstraint>

table check constraints.

getTableDefaultValues()

Obtains the default value constraints information for the named table.

public getTableDefaultValues(string $name[, bool $refresh = false ]) : array<string|int, DefaultValueConstraint>
Parameters
$name : string

table name. The table name may contain schema name if any. Do not quote the table name.

$refresh : bool = false

whether to reload the information even if it is found in the cache.

Return values
array<string|int, DefaultValueConstraint>

table default value constraints.

getTableForeignKeys()

Obtains the foreign keys information for the named table.

public getTableForeignKeys(string $name[, bool $refresh = false ]) : array<string|int, ForeignKeyConstraint>
Parameters
$name : string

table name. The table name may contain schema name if any. Do not quote the table name.

$refresh : bool = false

whether to reload the information even if it is found in the cache.

Return values
array<string|int, ForeignKeyConstraint>

table foreign keys.

getTableIndexes()

Obtains the indexes information for the named table.

public getTableIndexes(string $name[, bool $refresh = false ]) : array<string|int, IndexConstraint>
Parameters
$name : string

table name. The table name may contain schema name if any. Do not quote the table name.

$refresh : bool = false

whether to reload the information even if it is found in the cache.

Return values
array<string|int, IndexConstraint>

table indexes.

getTableNames()

Returns all table names in the database.

public getTableNames([string $schema = '' ][, bool $refresh = false ]) : array<string|int, string>
Parameters
$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 : bool = false

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

Return values
array<string|int, string>

all table names in the database.

getTablePrimaryKey()

Obtains the primary key for the named table.

public getTablePrimaryKey(string $name[, bool $refresh = false ]) : Constraint|null
Parameters
$name : string

table name. The table name may contain schema name if any. Do not quote the table name.

$refresh : bool = false

whether to reload the information even if it is found in the cache.

Return values
Constraint|null

table primary key, null if the table has no primary key.

getTableSchema()

Obtains the metadata for the named table.

public getTableSchema(string $name[, bool $refresh = false ]) : TableSchema|null
Parameters
$name : string

table name. The table name may contain schema name if any. Do not quote the table name.

$refresh : bool = false

whether to reload the table schema even if it is found in the cache.

Return values
TableSchema|null

table metadata. null if the named table does not exist.

getTableSchemas()

Returns the metadata for all tables in the database.

public getTableSchemas([string $schema = '' ][, bool $refresh = false ]) : array<string|int, TableSchema>
Parameters
$schema : string = ''

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

$refresh : bool = false

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

Return values
array<string|int, TableSchema>

the metadata for all tables in the database. Each array element is an instance of [[TableSchema]] or its child class.

getTableUniques()

Obtains the unique constraints information for the named table.

public getTableUniques(string $name[, bool $refresh = false ]) : array<string|int, Constraint>
Parameters
$name : string

table name. The table name may contain schema name if any. Do not quote the table name.

$refresh : bool = false

whether to reload the information even if it is found in the cache.

Return values
array<string|int, Constraint>

table unique constraints.

hasMethod()

Returns a value indicating whether a method is defined.

public hasMethod(string $name) : bool

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

Parameters
$name : string

the method name

Return values
bool

whether the method is defined

hasProperty()

Returns a value indicating whether a property is defined.

public hasProperty(string $name[, bool $checkVars = true ]) : bool

A property is defined if:

  • the class has a getter or setter method associated with the specified name (in this case, property name is case-insensitive);
  • the class has a member variable with the specified name (when $checkVars is true);
Parameters
$name : string

the property name

$checkVars : bool = true

whether to treat member variables as properties

Tags
see
canGetProperty()
see
canSetProperty()
Return values
bool

whether the property is defined

init()

Initializes the object.

public init() : mixed

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

insert()

Executes the INSERT command, returning primary key values.

public insert(string $table, array<string|int, mixed> $columns) : array<string|int, mixed>|false
Parameters
$table : string

the table that new rows will be inserted into.

$columns : array<string|int, mixed>

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

Tags
since
2.0.4
Return values
array<string|int, mixed>|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) : bool
Parameters
$sql : string

the SQL statement

Return values
bool

whether a SQL statement is for read purpose.

quoteColumnName()

Quotes a column name for use in a query.

public quoteColumnName(string $name) : string

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.

Parameters
$name : string

column name

Tags
see
quoteSimpleColumnName()
Return values
string

the properly quoted column name

quoteSimpleColumnName()

Quotes a simple column name for use in a query.

public quoteSimpleColumnName(string $name) : string

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.

Parameters
$name : string

column name

Return values
string

the properly quoted column name

quoteSimpleTableName()

Quotes a simple table name for use in a query.

public quoteSimpleTableName(string $name) : string

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.

Parameters
$name : string

table name

Return values
string

the properly quoted table name

quoteTableName()

Quotes a table name for use in a query.

public quoteTableName(string $name) : string

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.

Parameters
$name : string

table name

Tags
see
quoteSimpleTableName()
Return values
string

the properly quoted table name

quoteValue()

Quotes a string value for use in a query.

public quoteValue(string $str) : string

Note that if the parameter is not a string, it will be returned without change.

Parameters
$str : string

string to be quoted

Tags
see
https://www.php.net/manual/en/function.PDO-quote.php
Return values
string

the properly quoted string

refresh()

Refreshes the schema.

public refresh() : mixed

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

refreshTableSchema()

Refreshes the particular table schema.

public refreshTableSchema(string $name) : mixed

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

Parameters
$name : string

table name.

Tags
since
2.0.6

releaseSavepoint()

Releases an existing savepoint.

public releaseSavepoint(mixed $name) : mixed
Parameters
$name : mixed

the savepoint name

rollBackSavepoint()

Rolls back to a previously created savepoint.

public rollBackSavepoint(string $name) : mixed
Parameters
$name : string

the savepoint name

setTransactionIsolationLevel()

Sets the isolation level of the current transaction.

public setTransactionIsolationLevel(mixed $level) : mixed
Parameters
$level : mixed

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.

Tags
see
https://www.cubrid.org/manual/en/9.3.0/sql/transaction.html#database-concurrency

supportsSavepoint()

public supportsSavepoint() : bool
Return values
bool

whether this DBMS supports savepoint.

unquoteSimpleColumnName()

Unquotes a simple column name.

public unquoteSimpleColumnName(string $name) : string

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.

Parameters
$name : string

column name.

Tags
since
2.0.14
Return values
string

unquoted column name.

unquoteSimpleTableName()

Unquotes a simple table name.

public unquoteSimpleTableName(string $name) : string

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.

Parameters
$name : string

table name.

Tags
since
2.0.14
Return values
string

unquoted table name.

createColumnSchema()

Creates a column schema for the database.

protected createColumnSchema() : ColumnSchema

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

Tags
throws
InvalidConfigException

if a column schema class cannot be created.

Return values
ColumnSchema

column schema instance.

findSchemaNames()

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

protected findSchemaNames() : array<string|int, mixed>

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

Tags
throws
NotSupportedException

if this method is not supported by the DBMS.

since
2.0.4
Return values
array<string|int, mixed>

all schema names in the database, except system schemas.

findTableNames()

Returns all table names in the database.

protected findTableNames([mixed $schema = '' ]) : array<string|int, mixed>
Parameters
$schema : mixed = ''

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

Return values
array<string|int, mixed>

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

getCacheKey()

Returns the cache key for the specified table name.

protected getCacheKey(string $name) : mixed
Parameters
$name : string

the table name.

Return values
mixed

the cache key.

getCacheTag()

Returns the cache tag name.

protected getCacheTag() : string

This allows [[refresh()]] to invalidate all cached table schemas.

Return values
string

the cache tag name

getColumnPhpType()

Extracts the PHP type from abstract DB type.

protected getColumnPhpType(ColumnSchema $column) : string
Parameters
$column : ColumnSchema

the column schema information

Return values
string

PHP type name

getSchemaMetadata()

Returns the metadata of the given type for all tables in the given schema.

protected abstract getSchemaMetadata(string $schema, string $type, bool $refresh) : array<string|int, mixed>
Parameters
$schema : string

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

$type : string

metadata type.

$refresh : bool

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

Return values
array<string|int, mixed>

array of metadata.

getTableMetadata()

Returns the metadata of the given type for the given table.

protected abstract getTableMetadata(string $name, string $type, bool $refresh) : mixed
Parameters
$name : string

table name. The table name may contain schema name if any. Do not quote the table name.

$type : string

metadata type.

$refresh : bool

whether to reload the table metadata even if it is found in the cache.

Return values
mixed

metadata.

getTableNameParts()

Splits full table name into parts

protected getTableNameParts(string $name) : array<string|int, mixed>
Parameters
$name : string
Tags
since
2.0.22
Return values
array<string|int, mixed>

loadColumnSchema()

Loads the column information into a [[ColumnSchema]] object.

protected loadColumnSchema(array<string|int, mixed> $info) : ColumnSchema
Parameters
$info : array<string|int, mixed>

column information

Return values
ColumnSchema

the column schema object

loadTableChecks()

{@inheritdoc}

protected loadTableChecks(mixed $tableName) : mixed
Parameters
$tableName : mixed
Tags
throws
NotSupportedException

if this method is called.

loadTableDefaultValues()

{@inheritdoc}

protected loadTableDefaultValues(mixed $tableName) : mixed
Parameters
$tableName : mixed
Tags
throws
NotSupportedException

if this method is called.

loadTableForeignKeys()

{@inheritdoc}

protected loadTableForeignKeys(mixed $tableName) : mixed
Parameters
$tableName : mixed

loadTableIndexes()

{@inheritdoc}

protected loadTableIndexes(mixed $tableName) : mixed
Parameters
$tableName : mixed

loadTablePrimaryKey()

{@inheritdoc}

protected loadTablePrimaryKey(mixed $tableName) : mixed
Parameters
$tableName : mixed

loadTableSchema()

Loads the metadata for the specified table.

protected loadTableSchema(mixed $name) : TableSchema|null
Parameters
$name : mixed

table name

Return values
TableSchema|null

DBMS-dependent table metadata, null if the table does not exist.

loadTableUniques()

{@inheritdoc}

protected loadTableUniques(mixed $tableName) : mixed
Parameters
$tableName : mixed

normalizePdoRowKeyCase()

Changes row's array key case to lower if PDO's one is set to uppercase.

protected normalizePdoRowKeyCase(array<string|int, mixed> $row, bool $multiple) : array<string|int, mixed>
Parameters
$row : array<string|int, mixed>

row's array or an array of row's arrays.

$multiple : bool

whether multiple rows or a single row passed.

Tags
since
2.0.13
Return values
array<string|int, mixed>

normalized row or rows.

resolveTableName()

Resolves the table name and schema name (if any).

protected resolveTableName(string $name) : TableSchema
Parameters
$name : string

the table name

Tags
throws
NotSupportedException

if this method is not supported by the DBMS.

since
2.0.13
Return values
TableSchema

[[TableSchema]] with resolved table, schema, etc. names.

setTableMetadata()

Sets the metadata of the given type for the given table.

protected setTableMetadata(string $name, string $type, mixed $data) : mixed
Parameters
$name : string

table name.

$type : string

metadata type.

$data : mixed

metadata.

Tags
since
2.0.13

loadTableConstraints()

Loads multiple types of constraints and returns the specified ones.

private loadTableConstraints(string $tableName, string $returnType) : mixed
Parameters
$tableName : string

table name.

$returnType : string

return type:

  • indexes
  • uniques
Return values
mixed

constraints.

loadTableMetadataFromCache()

Tries to load and populate table metadata from cache.

private loadTableMetadataFromCache(Cache|null $cache, string $name) : mixed
Parameters
$cache : Cache|null
$name : string

saveTableMetadataToCache()

Saves table metadata to cache.

private saveTableMetadataToCache(Cache|null $cache, string $name) : mixed
Parameters
$cache : Cache|null
$name : string

        
On this page

Search results