-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f201623
commit d70cd6d
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/** | ||
* @author Semenov Alexander <[email protected]> | ||
* @link http://skeeks.com/ | ||
* @copyright 2010 SkeekS (СкикС) | ||
* @date 18.03.2016 | ||
*/ | ||
namespace skeeks\cms\dbDumper\console\controllers; | ||
|
||
use Yii; | ||
use yii\console\controllers\MigrateController; | ||
use yii\helpers\ArrayHelper; | ||
use yii\helpers\Console; | ||
use yii\helpers\FileHelper; | ||
|
||
/** | ||
* Working with the mysql database | ||
* | ||
* Class DbController | ||
* @package skeeks\cms\dbDumper\console\controllers | ||
*/ | ||
class MysqlController extends \yii\console\Controller | ||
{ | ||
public $defaultAction = "dump"; | ||
|
||
/** | ||
* Restore from the file dump | ||
* @param null $fileName The path to the dump file | ||
*/ | ||
public function actionRestore($fileName = null) | ||
{ | ||
try | ||
{ | ||
$this->stdout("The installation process is running the database\n"); | ||
\Yii::$app->dbDumper->restore($fileName); | ||
$this->stdout("Dump successfully installed\n", Console::FG_GREEN); | ||
} catch(\Exception $e) | ||
{ | ||
$this->stdout("In the process of restoring the dump occurred error: {$e->getMessage()}\n", Console::FG_RED); | ||
} | ||
} | ||
|
||
/** | ||
* Creating a dump | ||
*/ | ||
public function actionDump() | ||
{ | ||
try | ||
{ | ||
$result = \Yii::$app->dbDumper->dump(); | ||
$this->stdout("Dump the database was created successfully: {$result}\n", Console::FG_GREEN); | ||
} catch(\Exception $e) | ||
{ | ||
$this->stdout("During the dump error occurred: {$e->getMessage()}\n", Console::FG_RED); | ||
} | ||
} | ||
|
||
} |