Browse Source

修改console/controllers/InitController.php文件,将clearDb方法改为命令行可访问的actionClearDb方法

wechat_public_accounts
linyaostalker 5 years ago
parent
commit
330b527eb2
  1. 2
      console/controllers/InitController.php

2
console/controllers/InitController.php

@ -63,7 +63,7 @@ class InitController extends Controller {
* TODO没有完善 * TODO没有完善
* 清空数据库 * 清空数据库
*/ */
public function clearDb() {
public function actionClearDb() {
Yii::$app->db->createCommand("SET FOREIGN_KEY_CHECKS = 0;")->execute(); Yii::$app->db->createCommand("SET FOREIGN_KEY_CHECKS = 0;")->execute();
$dbname = explode('=', explode(';', Yii::$app->db->dsn)[1])[1]; $dbname = explode('=', explode(';', Yii::$app->db->dsn)[1])[1];
$sql = "SELECT CONCAT('drop table ',table_name,';') FROM information_schema.`TABLES` WHERE table_schema='{$dbname}';"; $sql = "SELECT CONCAT('drop table ',table_name,';') FROM information_schema.`TABLES` WHERE table_schema='{$dbname}';";

Loading…
Cancel
Save