@@ -38,38 +38,52 @@ The package could be installed with composer:
3838composer require yiisoft/cache-db --prefer-dist
3939```
4040
41+ ## Create database connection
42+
43+ For more information see [ yiisoft/db] ( https://github.com/yiisoft/db/tree/master/docs/en#create-connection ) .
44+
4145## Database Preparing
4246
4347Package provides two way for preparing database:
4448
45491 . Raw SQL. You can use it with the migration package used in your application.
4650
47- - [ MSSQL] ( /docs/en/migration/schema-mssql.sql ) ,
48- - [ MySQL / MariaDB] ( /docs/en/migration/schema-mysql.sql ) ,
49- - [ Oracle] ( /docs/en/migration/schema-oci.sql ) ,
50- - [ PostgreSQL] ( /docs/en/migration/schema-pgsql.sql ) ,
51- - [ SQLite] ( /docs/en/migration/schema-sqlite.sql ) ,
51+ - Ensure tables:
52+ - [ MSSQL] ( /sql/sqlsrv-up.sql ) ,
53+ - [ MySQL / MariaDB] ( /sql/mysql-up.sql ) ,
54+ - [ Oracle] ( /sql/oci-up.sql ) ,
55+ - [ PostgreSQL] ( /sql/pgsql-up.sql )
56+ - [ SQLite] ( /sql/sqlite-up.sql )
57+
58+ - Ensure no tables:
59+ - [ MSSQL] ( /sql/sqlsrv-down.sql ) ,
60+ - [ MySQL / MariaDB] ( /sql/mysql-down.sql ) ,
61+ - [ Oracle] ( /sql/oci-down.sql ) ,
62+ - [ PostgreSQL] ( /sql/pgsql-down.sql )
63+ - [ SQLite] ( /sql/sqlite-down.sql )
5264
53- 2 . ` DbHelper ` for create/drop cache table (by default ` {{%cache }} ` ).
65+ 2 . ` DbSchemaManager ` for ` ensureTable() ` , ` ensureNoTable() ` methods for cache table (by default ` {{%yii_cache }} ` ).
5466
5567``` php
56- // Create table with default name
57- DbHelper::ensureTable($db);
68+ // Create db schema manager
69+ $dbSchemaManager = new DbSchemaManager($db);
70+
71+ // Ensure table with default name
72+ $dbSchemaManager->ensureTable();
5873
59- // Create table with custom name
60- DbHelper:: ensureTable($db, '{{%custom_cache_table}}');
74+ // Ensure table with custom name
75+ $dbSchemaManager-> ensureTable('{{%custom_cache_table}}');
6176
62- // Drop table with default name
63- DbHelper::dropTable($db );
77+ // Ensure no table with default name
78+ $dbSchemaManager->ensureNoTable( );
6479
65- // Drop table with custom name
66- DbHelper::dropTable($db, '{{%custom_cache_table}}');
80+ // Ensure no table with custom name
81+ $dbSchemaManager->ensureNoTable( '{{%custom_cache_table}}');
6782```
6883
6984## Configuration
7085
71- When creating an instance of ` \Yiisoft\Cache\Db\DbCache ` , you must pass an instance of the database connection,
72- for more information see [ yiisoft/db] ( https://github.com/yiisoft/db/tree/master/docs/en#create-connection ) .
86+ When creating an instance of ` \Yiisoft\Cache\Db\DbCache ` , you must pass an instance of the database connection.
7387
7488``` php
7589$cache = new \Yiisoft\Cache\Db\DbCache($db, $table, $gcProbability);
0 commit comments