|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
-
-
- namespace yii\test;
-
- use Yii;
-
-
- class InitDbFixture extends DbFixture
- {
-
-
- public $initScript = '@app/tests/fixtures/initdb.php';
-
-
- public $schemas = [''];
-
-
-
-
- public function beforeLoad()
- {
- $this->checkIntegrity(false);
- }
-
-
-
- public function afterLoad()
- {
- $this->checkIntegrity(true);
- }
-
-
-
- public function load()
- {
- $file = Yii::getAlias($this->initScript);
- if (is_file($file)) {
- require($file);
- }
- }
-
-
-
- public function beforeUnload()
- {
- $this->checkIntegrity(false);
- }
-
-
-
- public function afterUnload()
- {
- $this->checkIntegrity(true);
- }
-
-
-
- public function checkIntegrity($check)
- {
- foreach ($this->schemas as $schema) {
- $this->db->createCommand()->checkIntegrity($check, $schema)->execute();
- }
- }
- }
|