Final Class Yiisoft\Cache\Db\DbSchemaManager
| Inheritance | Yiisoft\Cache\Db\DbSchemaManager |
|---|
Manages the cache table schema in the database.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Cache\Db\DbSchemaManager | |
| ensureNoTable() | Ensures that the cache table does not exist in the database. | Yiisoft\Cache\Db\DbSchemaManager |
| ensureTable() | Ensures that the cache table exists in the database. | Yiisoft\Cache\Db\DbSchemaManager |
Method Details
| public mixed __construct ( \Yiisoft\Db\Connection\ConnectionInterface $db ) | ||
| $db | \Yiisoft\Db\Connection\ConnectionInterface | |
public function __construct(private readonly ConnectionInterface $db)
{
}
Ensures that the cache table does not exist in the database.
| public void ensureNoTable ( string $table = '{{%yii_cache}}' ) | ||
| $table | string |
The name of the cache table. Defaults to '{{%yii_cache}}'. |
| throws | \Yiisoft\Db\Exception\Exception | |
|---|---|---|
| throws | \Yiisoft\Db\Exception\InvalidConfigException | |
| throws | Throwable | |
public function ensureNoTable(string $table = '{{%yii_cache}}'): void
{
$rawTableName = $this->db->getQuoter()->getRawTableName($table);
if ($this->hasTable($rawTableName)) {
$this->db->createCommand()->dropTable($rawTableName)->execute();
}
}
Ensures that the cache table exists in the database.
| public void ensureTable ( string $table = '{{%yii_cache}}' ) | ||
| $table | string |
The name of the cache table. Defaults to '{{%yii_cache}}'. |
| throws | \Yiisoft\Db\Exception\Exception | |
|---|---|---|
| throws | \Yiisoft\Db\Exception\NotSupportedException | |
| throws | \Yiisoft\Db\Exception\InvalidConfigException | |
| throws | Throwable | |
public function ensureTable(string $table = '{{%yii_cache}}'): void
{
$tableRawName = $this->db->getQuoter()->getRawTableName($table);
if ($this->hasTable($tableRawName)) {
return;
}
$this->db->createCommand()->createTable(
$table,
[
'id' => $this->db->getColumnBuilderClass()::string(128)->notNull(),
'data' => $this->db->getColumnBuilderClass()::binary(),
'expire' => $this->db->getColumnBuilderClass()::integer(),
"CONSTRAINT [[PK_$tableRawName]] PRIMARY KEY ([[id]])",
],
)->execute();
}
Signup or Login in order to comment.