Merge pull request #10618 from githubjeka/ar-refac

nya
This commit is contained in:
Alexander Makarov
2016-01-19 15:27:49 +03:00
2 changed files with 9 additions and 6 deletions

View File

@@ -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;
} }
/** /**

View File

@@ -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)
{ {