類別 yii\db\cubrid\Schema
Schema 類別用於從 CUBRID 資料庫(9.3.x 及更高版本)檢索元數據。
公開屬性
公用方法
受保護的方法
常數
常數 | 值 | 描述 | 定義於 |
---|---|---|---|
SCHEMA_CACHE_VERSION | 1 | 綱要快取版本,用於在快取資料格式變更時偵測快取值中的不相容性。 | yii\db\Schema |
TYPE_BIGINT | 'bigint' | yii\db\Schema | |
TYPE_BIGPK | 'bigpk' | yii\db\Schema | |
TYPE_BINARY | 'binary' | yii\db\Schema | |
TYPE_BOOLEAN | 'boolean' | yii\db\Schema | |
TYPE_CHAR | 'char' | yii\db\Schema | |
TYPE_DATE | 'date' | yii\db\Schema | |
TYPE_DATETIME | 'datetime' | yii\db\Schema | |
TYPE_DECIMAL | 'decimal' | yii\db\Schema | |
TYPE_DOUBLE | 'double' | yii\db\Schema | |
TYPE_FLOAT | 'float' | yii\db\Schema | |
TYPE_INTEGER | 'integer' | yii\db\Schema | |
TYPE_JSON | 'json' | yii\db\Schema | |
TYPE_MONEY | 'money' | yii\db\Schema | |
TYPE_PK | 'pk' | yii\db\Schema | |
TYPE_SMALLINT | 'smallint' | yii\db\Schema | |
TYPE_STRING | 'string' | yii\db\Schema | |
TYPE_TEXT | 'text' | yii\db\Schema | |
TYPE_TIME | 'time' | yii\db\Schema | |
TYPE_TIMESTAMP | 'timestamp' | yii\db\Schema | |
TYPE_TINYINT | 'tinyint' | yii\db\Schema | |
TYPE_UBIGPK | 'ubigpk' | yii\db\Schema | |
TYPE_UPK | 'upk' | yii\db\Schema |
屬性詳細資訊
DB 錯誤與對應例外狀況的對應表。如果在 DB 錯誤訊息中找到左側部分,則使用右側部分的例外狀況類別。
'Operation would have caused one or more unique constraint violations' => 'yii\db\IntegrityException',
]
用於引用綱要、表格等名稱的字元。如果開始和結束字元不同,則可以使用 2 個字元的陣列。
從實體欄位類型(鍵)到抽象欄位類型(值)的對應。有關資料類型的詳細資訊,請參閱 CUBRID 手冊。
'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' => self::TYPE_DATE,
'time' => self::TYPE_TIME,
'timestamp' => self::TYPE_TIMESTAMP,
'datetime' => self::TYPE_DATETIME,
'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' => self::TYPE_BINARY,
'clob' => self::TYPE_BINARY,
'bit' => self::TYPE_INTEGER,
'bit varying' => self::TYPE_INTEGER,
'set' => self::TYPE_STRING,
'multiset' => self::TYPE_STRING,
'list' => self::TYPE_STRING,
'sequence' => self::TYPE_STRING,
'enum' => self::TYPE_STRING,
]
方法詳細資訊
public mixed __call ( $name, $params ) | ||
$name | string |
方法名稱 |
$params | array |
方法參數 |
return | mixed |
方法傳回值 |
---|---|---|
throws | yii\base\UnknownMethodException |
當呼叫未知方法時 |
public function __call($name, $params)
{
throw new UnknownMethodException('Calling unknown method: ' . get_class($this) . "::$name()");
}
定義於: yii\base\BaseObject::__construct()
建構子。
預設實作執行兩項操作
- 使用給定的配置
$config
初始化物件。 - 呼叫 init()。
如果子類別中覆寫了此方法,建議
- 建構子的最後一個參數是配置陣列,例如此處的
$config
。 - 在建構子的結尾呼叫父類別實作。
public void __construct ( $config = [] ) | ||
$config | array |
將用於初始化物件屬性的名稱-值對 |
public function __construct($config = [])
{
if (!empty($config)) {
Yii::configure($this, $config);
}
$this->init();
}
定義於: yii\base\BaseObject::__get()
傳回物件屬性的值。
請勿直接呼叫此方法,因為它是 PHP 魔術方法,當執行 $value = $object->property;
時,將會隱含地呼叫它。
另請參閱 __set()。
public mixed __get ( $name ) | ||
$name | string |
屬性名稱 |
return | mixed |
屬性值 |
---|---|---|
throws | yii\base\UnknownPropertyException |
如果屬性未定義 |
throws | yii\base\InvalidCallException |
如果屬性為唯寫 |
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);
}
定義於: yii\base\BaseObject::__isset()
檢查屬性是否已設定,即已定義且非空值。
請勿直接呼叫此方法,因為它是 PHP 魔術方法,當執行 isset($object->property)
時,將會隱含地呼叫它。
請注意,如果屬性未定義,將傳回 false。
public boolean __isset ( $name ) | ||
$name | string |
屬性名稱或事件名稱 |
return | boolean |
指定的屬性是否已設定(非 null)。 |
---|
public function __isset($name)
{
$getter = 'get' . $name;
if (method_exists($this, $getter)) {
return $this->$getter() !== null;
}
return false;
}
定義於: yii\base\BaseObject::__set()
設定物件屬性的值。
請勿直接呼叫此方法,因為它是 PHP 魔術方法,當執行 $object->property = $value;
時,將會隱含地呼叫它。
另請參閱 __get()。
public void __set ( $name, $value ) | ||
$name | string |
屬性名稱或事件名稱 |
$value | mixed |
屬性值 |
throws | yii\base\UnknownPropertyException |
如果屬性未定義 |
---|---|---|
throws | yii\base\InvalidCallException |
如果屬性為唯讀 |
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);
}
}
定義於: yii\base\BaseObject::__unset()
將物件屬性設定為 null。
請勿直接呼叫此方法,因為它是 PHP 魔術方法,當執行 unset($object->property)
時,將會隱含地呼叫它。
請注意,如果屬性未定義,此方法將不會執行任何操作。如果屬性為唯讀,則會擲回例外狀況。
public void __unset ( $name ) | ||
$name | string |
屬性名稱 |
throws | yii\base\InvalidCallException |
如果屬性為唯讀。 |
---|
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);
}
}
定義於: yii\base\BaseObject::canGetProperty()
傳回一個值,指示屬性是否可以讀取。
如果符合以下條件,屬性是可讀取的
- 類別具有與指定名稱關聯的 getter 方法(在這種情況下,屬性名稱不區分大小寫);
- 類別具有具有指定名稱的成員變數(當
$checkVars
為 true 時);
另請參閱 canSetProperty()。
public boolean canGetProperty ( $name, $checkVars = true ) | ||
$name | string |
屬性名稱 |
$checkVars | boolean |
是否將成員變數視為屬性 |
return | boolean |
屬性是否可以讀取 |
---|
public function canGetProperty($name, $checkVars = true)
{
return method_exists($this, 'get' . $name) || $checkVars && property_exists($this, $name);
}
定義於: yii\base\BaseObject::canSetProperty()
傳回一個值,指示屬性是否可以設定。
如果符合以下條件,屬性是可寫入的
- 類別具有與指定名稱關聯的 setter 方法(在這種情況下,屬性名稱不區分大小寫);
- 類別具有具有指定名稱的成員變數(當
$checkVars
為 true 時);
另請參閱 canGetProperty()。
public boolean canSetProperty ( $name, $checkVars = true ) | ||
$name | string |
屬性名稱 |
$checkVars | boolean |
是否將成員變數視為屬性 |
return | boolean |
屬性是否可以寫入 |
---|
public function canSetProperty($name, $checkVars = true)
{
return method_exists($this, 'set' . $name) || $checkVars && property_exists($this, $name);
}
::class
。
定義於: yii\base\BaseObject::className()
傳回此類別的完整限定名稱。
public static string className ( ) | ||
return | string |
此類別的完整限定名稱。 |
---|
public static function className()
{
return get_called_class();
}
定義於: yii\db\Schema::convertException()
如果可能,將 DB 例外狀況轉換為更具體的例外狀況。
public yii\db\Exception convertException ( Exception $e, $rawSql ) | ||
$e | 例外狀況 | |
$rawSql | string |
產生例外狀況的 SQL |
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);
}
protected yii\db\ColumnSchema createColumnSchema ( ) | ||
return | yii\db\ColumnSchema |
欄位綱要實例。 |
---|---|---|
throws | yii\base\InvalidConfigException |
如果無法建立欄位綱要類別。 |
protected function createColumnSchema()
{
return Yii::createObject($this->columnSchemaClass);
}
建立欄位綱要建構器實例,並提供類型和值精度。
子類別可以覆寫此方法,以建立 DBMS 特定的欄位綱要建構器。
public yii\db\ColumnSchemaBuilder createColumnSchemaBuilder ( $type, $length = null ) | ||
$type | string |
欄位的類型。請參閱 yii\db\cubrid\ColumnSchemaBuilder::$type。 |
$length | integer|string|array|null |
欄位的長度或精度。請參閱 yii\db\cubrid\ColumnSchemaBuilder::$length。 |
return | yii\db\ColumnSchemaBuilder |
欄位綱要建構器實例 |
---|
public function createColumnSchemaBuilder($type, $length = null)
{
return new ColumnSchemaBuilder($type, $length, $this->db);
}
為 CUBRID 資料庫建立查詢建構器。
public yii\db\cubrid\QueryBuilder createQueryBuilder ( ) | ||
return | yii\db\cubrid\QueryBuilder |
查詢建構器實例 |
---|
public function createQueryBuilder()
{
return Yii::createObject(QueryBuilder::className(), [$this->db]);
}
定義於: yii\db\Schema::createSavepoint()
建立新的儲存點。
public void createSavepoint ( $name ) | ||
$name | string |
儲存點名稱 |
public function createSavepoint($name)
{
$this->db->createCommand("SAVEPOINT $name")->execute();
}
protected array findSchemaNames ( ) | ||
return | array |
資料庫中除了系統綱要以外的所有綱要名稱。 |
---|---|---|
throws | yii\base\NotSupportedException |
如果 DBMS 不支援此方法。 |
protected function findSchemaNames()
{
throw new NotSupportedException(get_class($this) . ' does not support fetching all schema names.');
}
傳回資料庫中所有表格名稱。
子類別應覆寫此方法以支援此功能,因為預設實作僅會拋出例外。
protected array findTableNames ( $schema = '' ) | ||
$schema | string |
資料表的 schema。預設為空字串,表示目前的或預設的 schema。 |
return | array |
資料庫中所有資料表名稱。名稱不帶有 schema 名稱前綴。 |
---|---|---|
throws | yii\base\NotSupportedException |
如果 DBMS 不支援此方法。 |
protected function findTableNames($schema = '')
{
$pdo = $this->db->getSlavePdo(true);
$tables = $pdo->cubrid_schema(\PDO::CUBRID_SCH_TABLE);
$tableNames = [];
foreach ($tables as $table) {
// do not list system tables
if ($table['TYPE'] != 0) {
$tableNames[] = $table['NAME'];
}
}
return $tableNames;
}
定義於: yii\db\Schema::findUniqueIndexes()
傳回給定表格的所有唯一索引。
每個陣列元素都具有以下結構
[
'IndexName1' => ['col1' [, ...]],
'IndexName2' => ['col2' [, ...]],
]
子類別應覆寫此方法以支援此功能,因為預設實作僅會拋出例外
public array findUniqueIndexes ( $table ) | ||
$table | yii\db\TableSchema |
資料表metadata |
return | array |
給定資料表的所有唯一索引。 |
---|---|---|
throws | yii\base\NotSupportedException |
如果呼叫此方法 |
public function findUniqueIndexes($table)
{
throw new NotSupportedException(get_class($this) . ' does not support getting unique indexes information.');
}
定義於: yii\db\Schema::getCacheKey()
傳回指定表格名稱的快取鍵。
protected mixed getCacheKey ( $name ) | ||
$name | string |
資料表名稱。 |
return | mixed |
快取鍵。 |
---|
protected function getCacheKey($name)
{
return [
__CLASS__,
$this->db->dsn,
$this->db->username,
$this->getRawTableName($name),
];
}
protected string getCacheTag ( ) | ||
return | string |
快取標籤名稱 |
---|
protected function getCacheTag()
{
return md5(serialize([
__CLASS__,
$this->db->dsn,
$this->db->username,
]));
}
定義於: yii\db\Schema::getColumnPhpType()
從抽象 DB 類型中提取 PHP 類型。
protected string getColumnPhpType ( $column ) | ||
$column | yii\db\ColumnSchema |
欄位 schema 資訊 |
return | string |
PHP 型別名稱 |
---|
protected function getColumnPhpType($column)
{
static $typeMap = [
// abstract type => php type
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';
}
定義於: yii\db\Schema::getLastInsertID()
傳回最後插入列或序列值的 ID。
另請參閱 https://php.dev.org.tw/manual/en/function.PDO-lastInsertId.php。
public string getLastInsertID ( $sequenceName = '' ) | ||
$sequenceName | string |
序列物件的名稱(某些 DBMS 要求) |
return | string |
最後插入的資料列的資料列 ID,或是從序列物件檢索的最後一個值 |
---|---|---|
throws | yii\base\InvalidCallException |
如果資料庫連線未啟用 |
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.');
}
判斷給定 PHP 資料值的 PDO 類型。
public integer getPdoType ( $data ) | ||
$data | mixed |
要判斷 PDO 型別的資料 |
return | integer |
PDO 型別 |
---|
public function getPdoType($data)
{
static $typeMap = [
// php type => PDO type
'boolean' => \PDO::PARAM_INT, // PARAM_BOOL is not supported by CUBRID PDO
'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;
}
public yii\db\QueryBuilder getQueryBuilder ( ) | ||
return | yii\db\QueryBuilder |
此連線的查詢建構器。 |
---|
public function getQueryBuilder()
{
if ($this->_builder === null) {
$this->_builder = $this->createQueryBuilder();
}
return $this->_builder;
}
定義於: yii\db\Schema::getRawTableName()
傳回給定表格名稱的實際名稱。
此方法將從給定的資料表名稱中移除大括號,並將百分比字元 '%' 替換為 yii\db\Connection::$tablePrefix。
public string getRawTableName ( $name ) | ||
$name | string |
要轉換的資料表名稱 |
return | string |
給定資料表名稱的真實名稱 |
---|
public function getRawTableName($name)
{
if (strpos($name, '{{') !== false) {
$name = preg_replace('/\\{\\{(.*?)\\}\\}/', '\1', $name);
return str_replace('%', $this->db->tablePrefix, $name);
}
return $name;
}
定義於: yii\db\ConstraintFinderTrait::getSchemaChecks()
傳回資料庫中所有表格的檢查約束。
public \yii\db\CheckConstraint[][] getSchemaChecks ( $schema = '', $refresh = false ) | ||
$schema | string |
資料表的 schema。預設為空字串,表示目前的或預設的 schema 名稱。 |
$refresh | boolean |
是否擷取最新的可用資料表 schema。如果為 false,則可能會傳回快取的資料(如果有的話)。 |
return | \yii\db\CheckConstraint[][] |
資料庫中所有資料表的 Check 條件約束。每個陣列元素都是 yii\db\CheckConstraint 或其子類別的陣列。 |
---|
public function getSchemaChecks($schema = '', $refresh = false)
{
return $this->getSchemaMetadata($schema, 'checks', $refresh);
}
定義於: yii\db\ConstraintFinderTrait::getSchemaDefaultValues()
傳回資料庫中所有表格的預設值約束。
public yii\db\DefaultValueConstraint[] getSchemaDefaultValues ( $schema = '', $refresh = false ) | ||
$schema | string |
資料表的 schema。預設為空字串,表示目前的或預設的 schema 名稱。 |
$refresh | boolean |
是否擷取最新的可用資料表 schema。如果為 false,則可能會傳回快取的資料(如果有的話)。 |
return | yii\db\DefaultValueConstraint[] |
資料庫中所有資料表的預設值條件約束。每個陣列元素都是 yii\db\DefaultValueConstraint 或其子類別的陣列。 |
---|
public function getSchemaDefaultValues($schema = '', $refresh = false)
{
return $this->getSchemaMetadata($schema, 'defaultValues', $refresh);
}
定義於: yii\db\ConstraintFinderTrait::getSchemaForeignKeys()
傳回資料庫中所有表格的外鍵。
public \yii\db\ForeignKeyConstraint[][] getSchemaForeignKeys ( $schema = '', $refresh = false ) | ||
$schema | string |
資料表的 schema。預設為空字串,表示目前的或預設的 schema 名稱。 |
$refresh | boolean |
是否擷取最新的可用資料表 schema。如果為 false,則可能會傳回快取的資料(如果有的話)。 |
return | \yii\db\ForeignKeyConstraint[][] |
資料庫中所有資料表的外來鍵。每個陣列元素都是 yii\db\ForeignKeyConstraint 或其子類別的陣列。 |
---|
public function getSchemaForeignKeys($schema = '', $refresh = false)
{
return $this->getSchemaMetadata($schema, 'foreignKeys', $refresh);
}
定義於: yii\db\ConstraintFinderTrait::getSchemaIndexes()
傳回資料庫中所有表格的索引。
public \yii\db\IndexConstraint[][] getSchemaIndexes ( $schema = '', $refresh = false ) | ||
$schema | string |
資料表的 schema。預設為空字串,表示目前的或預設的 schema 名稱。 |
$refresh | boolean |
是否擷取最新的可用資料表 schema。如果為 false,則可能會傳回快取的資料(如果有的話)。 |
return | \yii\db\IndexConstraint[][] |
資料庫中所有資料表的索引。每個陣列元素都是 yii\db\IndexConstraint 或其子類別的陣列。 |
---|
public function getSchemaIndexes($schema = '', $refresh = false)
{
return $this->getSchemaMetadata($schema, 'indexes', $refresh);
}
定義於: yii\db\ConstraintFinderTrait::getSchemaMetadata()
傳回給定綱要中所有表格的給定類型元數據。
protected abstract array getSchemaMetadata ( $schema, $type, $refresh ) | ||
$schema | string |
metadata 的 schema。預設為空字串,表示目前的或預設的 schema 名稱。 |
$type | string |
Metadata 型別。 |
$refresh | boolean |
是否擷取最新的可用資料表 metadata。如果為 |
return | array |
Metadata 陣列。 |
---|
abstract protected function getSchemaMetadata($schema, $type, $refresh);
定義於: yii\db\Schema::getSchemaNames()
傳回資料庫中除了系統綱要以外的所有綱要名稱。
public string[] getSchemaNames ( $refresh = false ) | ||
$refresh | boolean |
是否擷取最新的可用 schema 名稱。如果為 false,則會傳回先前擷取的 schema 名稱(如果有的話)。 |
return | string[] |
資料庫中除了系統綱要以外的所有綱要名稱。 |
---|
public function getSchemaNames($refresh = false)
{
if ($this->_schemaNames === null || $refresh) {
$this->_schemaNames = $this->findSchemaNames();
}
return $this->_schemaNames;
}
定義於: yii\db\ConstraintFinderTrait::getSchemaPrimaryKeys()
傳回資料庫中所有表格的主鍵。
public yii\db\Constraint[] getSchemaPrimaryKeys ( $schema = '', $refresh = false ) | ||
$schema | string |
資料表的 schema。預設為空字串,表示目前的或預設的 schema 名稱。 |
$refresh | boolean |
是否擷取最新的可用資料表 schema。如果為 |
return | yii\db\Constraint[] |
資料庫中所有資料表的主鍵。每個陣列元素都是 yii\db\Constraint 或其子類別的實例。 |
---|
public function getSchemaPrimaryKeys($schema = '', $refresh = false)
{
return $this->getSchemaMetadata($schema, 'primaryKey', $refresh);
}
定義於: yii\db\ConstraintFinderTrait::getSchemaUniques()
傳回資料庫中所有表格的唯一約束。
public \yii\db\Constraint[][] getSchemaUniques ( $schema = '', $refresh = false ) | ||
$schema | string |
資料表的 schema。預設為空字串,表示目前的或預設的 schema 名稱。 |
$refresh | boolean |
是否擷取最新的可用資料表 schema。如果為 false,則可能會傳回快取的資料(如果有的話)。 |
return | \yii\db\Constraint[][] |
資料庫中所有資料表的唯一條件約束。每個陣列元素都是 yii\db\Constraint 或其子類別的陣列。 |
---|
public function getSchemaUniques($schema = '', $refresh = false)
{
return $this->getSchemaMetadata($schema, 'uniques', $refresh);
}
定義於: yii\db\Schema::getServerVersion()
傳回伺服器版本,以字串形式,可使用 \version_compare() 比較。
public string getServerVersion ( ) | ||
return | string |
伺服器版本,以字串表示。 |
---|
public function getServerVersion()
{
if ($this->_serverVersion === null) {
$this->_serverVersion = $this->db->getSlavePdo(true)->getAttribute(\PDO::ATTR_SERVER_VERSION);
}
return $this->_serverVersion;
}
定義於: yii\db\ConstraintFinderTrait::getTableChecks()
取得指定表格的檢查約束資訊。
public yii\db\CheckConstraint[] getTableChecks ( $name, $refresh = false ) | ||
$name | string |
資料表名稱。資料表名稱可能包含 schema 名稱(如果有的話)。請勿引用資料表名稱。 |
$refresh | boolean |
是否重新載入資訊,即使在快取中找到亦然。 |
return | yii\db\CheckConstraint[] |
資料表 Check 條件約束。 |
---|
public function getTableChecks($name, $refresh = false)
{
return $this->getTableMetadata($name, 'checks', $refresh);
}
定義於: yii\db\ConstraintFinderTrait::getTableDefaultValues()
取得指定表格的預設值約束資訊。
public yii\db\DefaultValueConstraint[] getTableDefaultValues ( $name, $refresh = false ) | ||
$name | string |
資料表名稱。資料表名稱可能包含 schema 名稱(如果有的話)。請勿引用資料表名稱。 |
$refresh | boolean |
是否重新載入資訊,即使在快取中找到亦然。 |
return | yii\db\DefaultValueConstraint[] |
資料表預設值條件約束。 |
---|
public function getTableDefaultValues($name, $refresh = false)
{
return $this->getTableMetadata($name, 'defaultValues', $refresh);
}
定義於: yii\db\ConstraintFinderTrait::getTableForeignKeys()
取得指定表格的外鍵資訊。
public yii\db\ForeignKeyConstraint[] getTableForeignKeys ( $name, $refresh = false ) | ||
$name | string |
資料表名稱。資料表名稱可能包含 schema 名稱(如果有的話)。請勿引用資料表名稱。 |
$refresh | boolean |
是否重新載入資訊,即使在快取中找到亦然。 |
return | yii\db\ForeignKeyConstraint[] |
資料表外來鍵。 |
---|
public function getTableForeignKeys($name, $refresh = false)
{
return $this->getTableMetadata($name, 'foreignKeys', $refresh);
}
定義於: yii\db\ConstraintFinderTrait::getTableIndexes()
取得指定表格的索引資訊。
public yii\db\IndexConstraint[] getTableIndexes ( $name, $refresh = false ) | ||
$name | string |
資料表名稱。資料表名稱可能包含 schema 名稱(如果有的話)。請勿引用資料表名稱。 |
$refresh | boolean |
是否重新載入資訊,即使在快取中找到亦然。 |
return | yii\db\IndexConstraint[] |
資料表索引。 |
---|
public function getTableIndexes($name, $refresh = false)
{
return $this->getTableMetadata($name, 'indexes', $refresh);
}
定義於: yii\db\ConstraintFinderTrait::getTableMetadata()
傳回給定表格的給定類型元數據。
protected abstract mixed getTableMetadata ( $name, $type, $refresh ) | ||
$name | string |
資料表名稱。資料表名稱可能包含 schema 名稱(如果有的話)。請勿引用資料表名稱。 |
$type | string |
Metadata 型別。 |
$refresh | boolean |
是否重新載入資料表 metadata,即使在快取中找到亦然。 |
return | mixed |
Metadata。 |
---|
abstract protected function getTableMetadata($name, $type, $refresh);
定義於: yii\db\Schema::getTableNameParts()
將完整表格名稱拆分為多個部分
protected array getTableNameParts ( $name ) | ||
$name | string |
protected function getTableNameParts($name)
{
return explode('.', $name);
}
定義於: yii\db\Schema::getTableNames()
傳回資料庫中所有表格名稱。
public string[] getTableNames ( $schema = '', $refresh = false ) | ||
$schema | string |
資料表的 schema。預設為空字串,表示目前的或預設的 schema 名稱。如果不為空,則傳回的資料表名稱將會加上 schema 名稱前綴。 |
$refresh | boolean |
是否擷取最新的可用資料表名稱。如果為 false,則會傳回先前擷取的資料表名稱(如果有的話)。 |
return | string[] |
資料庫中所有表格名稱。 |
---|
public function getTableNames($schema = '', $refresh = false)
{
if (!isset($this->_tableNames[$schema]) || $refresh) {
$this->_tableNames[$schema] = $this->findTableNames($schema);
}
return $this->_tableNames[$schema];
}
定義於: yii\db\ConstraintFinderTrait::getTablePrimaryKey()
取得指定表格的主鍵。
public yii\db\Constraint|null getTablePrimaryKey ( $name, $refresh = false ) | ||
$name | string |
資料表名稱。資料表名稱可能包含 schema 名稱(如果有的話)。請勿引用資料表名稱。 |
$refresh | boolean |
是否重新載入資訊,即使在快取中找到亦然。 |
return | yii\db\Constraint|null |
資料表主鍵,如果資料表沒有主鍵,則為 |
---|
public function getTablePrimaryKey($name, $refresh = false)
{
return $this->getTableMetadata($name, 'primaryKey', $refresh);
}
定義於: yii\db\Schema::getTableSchema()
取得指定表格的元數據。
public yii\db\TableSchema|null getTableSchema ( $name, $refresh = false ) | ||
$name | string |
資料表名稱。資料表名稱可能包含 schema 名稱(如果有的話)。請勿引用資料表名稱。 |
$refresh | boolean |
是否重新載入資料表 schema,即使在快取中找到亦然。 |
return | yii\db\TableSchema|null |
資料表 metadata。如果指定的資料表不存在,則為 |
---|
public function getTableSchema($name, $refresh = false)
{
return $this->getTableMetadata($name, 'schema', $refresh);
}
定義於: yii\db\Schema::getTableSchemas()
傳回資料庫中所有表格的元數據。
public yii\db\TableSchema[] getTableSchemas ( $schema = '', $refresh = false ) | ||
$schema | string |
資料表的 schema。預設為空字串,表示目前的或預設的 schema 名稱。 |
$refresh | boolean |
是否擷取最新的可用資料表 schema。如果為 |
return | yii\db\TableSchema[] |
資料庫中所有資料表的 metadata。每個陣列元素都是 yii\db\TableSchema 或其子類別的實例。 |
---|
public function getTableSchemas($schema = '', $refresh = false)
{
return $this->getSchemaMetadata($schema, 'schema', $refresh);
}
Defined in: yii\db\ConstraintFinderTrait::getTableUniques()
取得指定表格的唯一約束資訊。
public yii\db\Constraint[] getTableUniques ( $name, $refresh = false ) | ||
$name | string |
資料表名稱。資料表名稱可能包含 schema 名稱(如果有的話)。請勿引用資料表名稱。 |
$refresh | boolean |
是否重新載入資訊,即使在快取中找到亦然。 |
return | yii\db\Constraint[] |
資料表唯一約束。 |
---|
public function getTableUniques($name, $refresh = false)
{
return $this->getTableMetadata($name, 'uniques', $refresh);
}
Defined in: yii\base\BaseObject::hasMethod()
傳回一個值,指示方法是否已定義。
預設實作是呼叫 php 函式 method_exists()
。當您實作 php 魔術方法 __call()
時,您可以覆寫此方法。
public boolean hasMethod ( $name ) | ||
$name | string |
方法名稱 |
return | boolean |
方法是否已定義 |
---|
public function hasMethod($name)
{
return method_exists($this, $name);
}
Defined in: yii\base\BaseObject::hasProperty()
傳回一個值,指示屬性是否已定義。
若符合下列條件,則屬性已定義
- 類別具有與指定名稱相關聯的 getter 或 setter 方法(在此情況下,屬性名稱不區分大小寫);
- 類別具有具有指定名稱的成員變數(當
$checkVars
為 true 時);
參見
public boolean hasProperty ( $name, $checkVars = true ) | ||
$name | string |
屬性名稱 |
$checkVars | boolean |
是否將成員變數視為屬性 |
return | boolean |
屬性是否已定義 |
---|
public function hasProperty($name, $checkVars = true)
{
return $this->canGetProperty($name, $checkVars) || $this->canSetProperty($name, false);
}
public void init ( ) |
public function init()
{
}
Defined in: yii\db\Schema::insert()
執行 INSERT 命令,傳回主鍵值。
public array|false insert ( $table, $columns ) | ||
$table | string |
將在其中插入新列的資料表。 |
$columns | array |
要插入資料表的欄位資料(name => value)。 |
return | array|false |
主鍵值,若命令失敗則為 false |
---|
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;
}
Defined in: yii\db\Schema::isReadQuery()
傳回一個值,指示 SQL 陳述式是否用於讀取目的。
public boolean isReadQuery ( $sql ) | ||
$sql | string |
SQL 陳述式 |
return | boolean |
SQL 陳述式是否用於讀取目的。 |
---|
public function isReadQuery($sql)
{
$pattern = '/^\s*(SELECT|SHOW|DESCRIBE)\b/i';
return preg_match($pattern, $sql) > 0;
}
將欄位資訊載入到 yii\db\ColumnSchema 物件中。
protected yii\db\ColumnSchema loadColumnSchema ( $info ) | ||
$info | array |
欄位資訊 |
return | yii\db\ColumnSchema |
欄位綱要物件 |
---|
protected function loadColumnSchema($info)
{
$column = $this->createColumnSchema();
$column->name = $info['Field'];
$column->allowNull = $info['Null'] === 'YES';
$column->isPrimaryKey = false; // primary key will be set by loadTableSchema() later
$column->autoIncrement = stripos($info['Extra'], 'auto_increment') !== false;
$column->dbType = $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]);
$column->dbType = $type . (isset($matches[2]) ? "({$matches[2]})" : '');
if (isset($this->typeMap[$type])) {
$column->type = $this->typeMap[$type];
}
if (!empty($matches[2])) {
if ($type === 'enum') {
$values = preg_split('/\s*,\s*/', $matches[2]);
foreach ($values as $i => $value) {
$values[$i] = trim($value, "'");
}
$column->enumValues = $values;
} else {
$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 === '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) {
return $column;
}
if (
$column->type === 'timestamp' && $info['Default'] === 'SYS_TIMESTAMP' ||
$column->type === 'datetime' && $info['Default'] === 'SYS_DATETIME' ||
$column->type === 'date' && $info['Default'] === 'SYS_DATE' ||
$column->type === 'time' && $info['Default'] === 'SYS_TIME'
) {
$column->defaultValue = new Expression($info['Default']);
} elseif (isset($type) && $type === 'bit') {
$column->defaultValue = hexdec(trim($info['Default'], 'X\''));
} else {
$column->defaultValue = $column->phpTypecast($info['Default']);
}
return $column;
}
protected void loadTableChecks ( $tableName ) | ||
$tableName | ||
throws | yii\base\NotSupportedException |
如果調用此方法。 |
---|
protected function loadTableChecks($tableName)
{
throw new NotSupportedException('CUBRID does not support check constraints.');
}
protected void loadTableDefaultValues ( $tableName ) | ||
$tableName | ||
throws | yii\base\NotSupportedException |
如果調用此方法。 |
---|
protected function loadTableDefaultValues($tableName)
{
throw new NotSupportedException('CUBRID does not support default value constraints.');
}
protected void loadTableForeignKeys ( $tableName ) | ||
$tableName |
protected function loadTableForeignKeys($tableName)
{
static $actionTypes = [
0 => 'CASCADE',
1 => 'RESTRICT',
2 => 'NO ACTION',
3 => 'SET NULL',
];
$foreignKeys = $this->db->getSlavePdo(true)->cubrid_schema(\PDO::CUBRID_SCH_IMPORTED_KEYS, $tableName);
$foreignKeys = ArrayHelper::index($foreignKeys, null, 'FK_NAME');
ArrayHelper::multisort($foreignKeys, 'KEY_SEQ', SORT_ASC, SORT_NUMERIC);
$result = [];
foreach ($foreignKeys as $name => $foreignKey) {
$result[] = new ForeignKeyConstraint([
'name' => $name,
'columnNames' => ArrayHelper::getColumn($foreignKey, 'FKCOLUMN_NAME'),
'foreignTableName' => $foreignKey[0]['PKTABLE_NAME'],
'foreignColumnNames' => ArrayHelper::getColumn($foreignKey, 'PKCOLUMN_NAME'),
'onDelete' => isset($actionTypes[$foreignKey[0]['DELETE_RULE']]) ? $actionTypes[$foreignKey[0]['DELETE_RULE']] : null,
'onUpdate' => isset($actionTypes[$foreignKey[0]['UPDATE_RULE']]) ? $actionTypes[$foreignKey[0]['UPDATE_RULE']] : null,
]);
}
return $result;
}
protected void loadTableIndexes ( $tableName ) | ||
$tableName |
protected function loadTableIndexes($tableName)
{
return $this->loadTableConstraints($tableName, 'indexes');
}
protected void loadTablePrimaryKey ( $tableName ) | ||
$tableName |
protected function loadTablePrimaryKey($tableName)
{
$primaryKey = $this->db->getSlavePdo(true)->cubrid_schema(\PDO::CUBRID_SCH_PRIMARY_KEY, $tableName);
if (empty($primaryKey)) {
return null;
}
ArrayHelper::multisort($primaryKey, 'KEY_SEQ', SORT_ASC, SORT_NUMERIC);
return new Constraint([
'name' => $primaryKey[0]['KEY_NAME'],
'columnNames' => ArrayHelper::getColumn($primaryKey, 'ATTR_NAME'),
]);
}
載入指定表格的元數據。
protected yii\db\TableSchema|null loadTableSchema ( $name ) | ||
$name | string |
資料表名稱 |
return | yii\db\TableSchema|null |
與 DBMS 相關的資料表中繼資料,如果資料表不存在則為 |
---|
protected function loadTableSchema($name)
{
$pdo = $this->db->getSlavePdo(true);
$tableInfo = $pdo->cubrid_schema(\PDO::CUBRID_SCH_TABLE, $name);
if (!isset($tableInfo[0]['NAME'])) {
return null;
}
$table = new TableSchema();
$table->fullName = $table->name = $tableInfo[0]['NAME'];
$sql = 'SHOW FULL COLUMNS FROM ' . $this->quoteSimpleTableName($table->name);
$columns = $this->db->createCommand($sql)->queryAll();
foreach ($columns as $info) {
$column = $this->loadColumnSchema($info);
$table->columns[$column->name] = $column;
}
$primaryKeys = $pdo->cubrid_schema(\PDO::CUBRID_SCH_PRIMARY_KEY, $table->name);
foreach ($primaryKeys as $key) {
$column = $table->columns[$key['ATTR_NAME']];
$column->isPrimaryKey = true;
$table->primaryKey[] = $column->name;
if ($column->autoIncrement) {
$table->sequenceName = '';
}
}
$foreignKeys = $pdo->cubrid_schema(\PDO::CUBRID_SCH_IMPORTED_KEYS, $table->name);
foreach ($foreignKeys as $key) {
if (isset($table->foreignKeys[$key['FK_NAME']])) {
$table->foreignKeys[$key['FK_NAME']][$key['FKCOLUMN_NAME']] = $key['PKCOLUMN_NAME'];
} else {
$table->foreignKeys[$key['FK_NAME']] = [
$key['PKTABLE_NAME'],
$key['FKCOLUMN_NAME'] => $key['PKCOLUMN_NAME'],
];
}
}
return $table;
}
protected void loadTableUniques ( $tableName ) | ||
$tableName |
protected function loadTableUniques($tableName)
{
return $this->loadTableConstraints($tableName, 'uniques');
}
Defined in: yii\db\Schema::normalizePdoRowKeyCase()
如果 PDO 的陣列鍵大小寫設定為大寫,則將列的陣列鍵大小寫變更為小寫。
protected array normalizePdoRowKeyCase ( array $row, $multiple ) | ||
$row | array |
列的陣列或列的陣列的陣列。 |
$multiple | boolean |
是否傳遞多列或單列。 |
return | array |
標準化的列或多列。 |
---|
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()
引用欄位名稱以用於查詢中。
如果欄位名稱包含前綴,前綴也會被正確地引用。如果欄位名稱已經被引用,或者包含 '('、'[[' 或 '{{',則此方法將不執行任何操作。
另請參閱 quoteSimpleColumnName()。
public string quoteColumnName ( $name ) | ||
$name | string |
欄位名稱 |
return | string |
正確引用的欄位名稱 |
---|
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()
引用簡單欄位名稱以用於查詢中。
簡單欄位名稱應僅包含欄位名稱,不含任何前綴。如果欄位名稱已經被引用,或是星號字元 '*',則此方法將不執行任何操作。
public string quoteSimpleColumnName ( $name ) | ||
$name | string |
欄位名稱 |
return | string |
正確引用的欄位名稱 |
---|
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()
引用簡單表格名稱以用於查詢中。
簡單資料表名稱應僅包含資料表名稱,不含任何綱要前綴。如果資料表名稱已經被引用,則此方法將不執行任何操作。
public string quoteSimpleTableName ( $name ) | ||
$name | string |
資料表名稱 |
return | string |
正確引用的資料表名稱 |
---|
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()
引用表格名稱以用於查詢中。
如果資料表名稱包含綱要前綴,前綴也會被正確地引用。如果資料表名稱已經被引用,或者包含 '(' 或 '{{',則此方法將不執行任何操作。
另請參閱 quoteSimpleTableName()。
public string quoteTableName ( $name ) | ||
$name | string |
資料表名稱 |
return | string |
正確引用的資料表名稱 |
---|
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);
}
Defined in: yii\db\Schema::quoteValue()
引用字串值以用於查詢中。
請注意,如果參數不是字串,它將在不變更的情況下傳回。
另請參閱 https://php.dev.org.tw/manual/en/function.PDO-quote.php。
public string quoteValue ( $str ) | ||
$str | string |
要引用的字串 |
return | string |
正確引用的字串 |
---|
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;
}
// the driver doesn't support quote (e.g. oci)
return "'" . addcslashes(str_replace("'", "''", $str), "\000\n\r\\\032") . "'";
}
public void refresh ( ) |
public function refresh()
{
/* @var $cache CacheInterface */
$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 = [];
}
public void refreshTableSchema ( $name ) | ||
$name | string |
資料表名稱。 |
public function refreshTableSchema($name)
{
$rawName = $this->getRawTableName($name);
unset($this->_tableMetadata[$rawName]);
$this->_tableNames = [];
/* @var $cache CacheInterface */
$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));
}
}
釋放現有的儲存點。
public void releaseSavepoint ( $name ) | ||
$name | string |
儲存點名稱 |
public function releaseSavepoint($name)
{
// does nothing as cubrid does not support this
}
Defined in: yii\db\Schema::resolveTableName()
解析表格名稱和綱要名稱(如果有的話)。
protected yii\db\TableSchema resolveTableName ( $name ) | ||
$name | string |
資料表名稱 |
return | yii\db\TableSchema |
yii\db\TableSchema,帶有已解析的資料表、綱要等名稱。 |
---|---|---|
throws | yii\base\NotSupportedException |
如果 DBMS 不支援此方法。 |
protected function resolveTableName($name)
{
throw new NotSupportedException(get_class($this) . ' does not support resolving table names.');
}
Defined in: yii\db\Schema::rollBackSavepoint()
回滾到先前建立的儲存點。
public void rollBackSavepoint ( $name ) | ||
$name | string |
儲存點名稱 |
public function rollBackSavepoint($name)
{
$this->db->createCommand("ROLLBACK TO SAVEPOINT $name")->execute();
}
Defined in: yii\db\Schema::setTableMetadata()
設定給定表格的給定類型元數據。
protected void setTableMetadata ( $name, $type, $data ) | ||
$name | string |
資料表名稱。 |
$type | string |
Metadata 型別。 |
$data | mixed |
Metadata。 |
protected function setTableMetadata($name, $type, $data)
{
$this->_tableMetadata[$this->getRawTableName($name)][$type] = $data;
}
public void setTransactionIsolationLevel ( $level ) | ||
$level | string |
用於此交易的交易隔離等級。這可以是 yii\db\Transaction::READ_UNCOMMITTED、yii\db\Transaction::READ_COMMITTED、yii\db\Transaction::REPEATABLE_READ 和 yii\db\Transaction::SERIALIZABLE 其中之一,也可以是包含 DBMS 特定語法的字串,用於 |
public function setTransactionIsolationLevel($level)
{
// translate SQL92 levels to CUBRID levels:
switch ($level) {
case Transaction::SERIALIZABLE:
$level = '6'; // SERIALIZABLE
break;
case Transaction::REPEATABLE_READ:
$level = '5'; // REPEATABLE READ CLASS with REPEATABLE READ INSTANCES
break;
case Transaction::READ_COMMITTED:
$level = '4'; // REPEATABLE READ CLASS with READ COMMITTED INSTANCES
break;
case Transaction::READ_UNCOMMITTED:
$level = '3'; // REPEATABLE READ CLASS with READ UNCOMMITTED INSTANCES
break;
}
parent::setTransactionIsolationLevel($level);
}
Defined in: yii\db\Schema::supportsSavepoint()
public boolean supportsSavepoint ( ) | ||
return | boolean |
此 DBMS 是否支援 savepoint。 |
---|
public function supportsSavepoint()
{
return $this->db->enableSavepoint;
}
Defined in: yii\db\Schema::unquoteSimpleColumnName()
取消引用簡單欄位名稱。
簡單欄位名稱應僅包含欄位名稱,不含任何前綴。如果欄位名稱未被引用,或是星號字元 '*',則此方法將不執行任何操作。
public string unquoteSimpleColumnName ( $name ) | ||
$name | string |
欄位名稱。 |
return | string |
未引用的欄位名稱。 |
---|
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()
取消引用簡單表格名稱。
簡單資料表名稱應僅包含資料表名稱,不含任何綱要前綴。如果資料表名稱未被引用,則此方法將不執行任何操作。
public string unquoteSimpleTableName ( $name ) | ||
$name | string |
資料表名稱。 |
return | string |
未引用的資料表名稱。 |
---|
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);
}
為了評論,請註冊或登入。