Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
skeeks-semenov committed Apr 21, 2016
1 parent f201623 commit d70cd6d
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions console/controllers/MysqlController.php
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);
}
}

}

0 comments on commit d70cd6d

Please sign in to comment.