public getTableSchema ( string $name, boolean $refresh = false ) : yii\db\TableSchema | ||
$name | string | table name. |
$refresh | boolean | whether to reload the table schema even if it is found in the cache. |
Résultat | yii\db\TableSchema | table schema information. Null if the named table does not exist. |
public function getTableSchema($name, $refresh = false)
{
return $this->getSchema()->getTableSchema($name, $refresh);
}
/** * Create table if not exists */ protected function createTable() { if ($this->db->getTableSchema($this->tableName) === null) { $this->db->createCommand()->createTable($this->tableName, ['id' => 'pk', 'created_at' => 'integer', 'updated_at' => 'integer', 'data' => 'binary'])->execute(); $this->db->getTableSchema($this->tableName, true); } }