mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-15 13:58:24 +08:00
@@ -291,12 +291,15 @@ class ActiveRecord extends BaseActiveRecord
|
|||||||
*/
|
*/
|
||||||
public static function getTableSchema()
|
public static function getTableSchema()
|
||||||
{
|
{
|
||||||
$schema = static::getDb()->getSchema()->getTableSchema(static::tableName());
|
$schema = static::getDb()
|
||||||
if ($schema !== null) {
|
->getSchema()
|
||||||
return $schema;
|
->getTableSchema(static::tableName());
|
||||||
} else {
|
|
||||||
|
if ($schema === null) {
|
||||||
throw new InvalidConfigException('The table does not exist: ' . static::tableName());
|
throw new InvalidConfigException('The table does not exist: ' . static::tableName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ abstract class Schema extends Object
|
|||||||
/**
|
/**
|
||||||
* Loads the metadata for the specified table.
|
* Loads the metadata for the specified table.
|
||||||
* @param string $name table name
|
* @param string $name table name
|
||||||
* @return TableSchema DBMS-dependent table metadata, null if the table does not exist.
|
* @return null|TableSchema DBMS-dependent table metadata, null if the table does not exist.
|
||||||
*/
|
*/
|
||||||
abstract protected function loadTableSchema($name);
|
abstract protected function loadTableSchema($name);
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ abstract class Schema extends Object
|
|||||||
* Obtains the metadata for the named table.
|
* Obtains the metadata for the named table.
|
||||||
* @param string $name table name. The table name may contain schema name if any. Do not quote the table name.
|
* @param string $name table name. The table name may contain schema name if any. Do not quote the table name.
|
||||||
* @param boolean $refresh whether to reload the table schema even if it is found in the cache.
|
* @param boolean $refresh whether to reload the table schema even if it is found in the cache.
|
||||||
* @return TableSchema table metadata. Null if the named table does not exist.
|
* @return null|TableSchema table metadata. Null if the named table does not exist.
|
||||||
*/
|
*/
|
||||||
public function getTableSchema($name, $refresh = false)
|
public function getTableSchema($name, $refresh = false)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user