src/controllers/DbController.php
public function actionRecreateViews ()
		{
			$db = Yii::$app->db;
			$views = $this->getViews();

			foreach ($views as $view)
			{
				$info = $db->createCommand("SHOW CREATE VIEW `$view`")->queryAll();
				$sql = $info[ 0 ][ 'Create View' ];
				preg_match("/.*VIEW `$view` as (.*)/i", $sql, $match);
				if (isset($match[ 1 ]))
				{
					$db->createCommand("CREATE OR REPLACE VIEW `$view` AS " . $match[ 1 ])->execute();
					Console::printColor("View `$view` was recreated.", "green");
				}
				else
				{
					Console::printColor("Cannot find create string for view `$view`.", "red");
				}
			}
		}
public function actionRecreateViews ()
		{
			$db = Yii::$app->db;
			$views = $this->getViews();

			foreach ($views as $view)
			{
				$info = $db->createCommand("SHOW CREATE VIEW `$view`")->queryAll();
				$sql = $info[ 0 ][ 'Create View' ];
				preg_match("/.*VIEW `$view` as (.*)/i", $sql, $match);
				if (isset($match[ 1 ]))
				{
					$db->createCommand("CREATE OR REPLACE VIEW `$view` AS " . $match[ 1 ])->execute();
					Console::printColor("View `$view` was recreated.", "green");
				}
				else
				{
					Console::printColor("Cannot find create string for view `$view`.", "red");
				}
			}
		}
public function actionRecreateViews ( ) { $ db = Yii :: $ app -> db ; $ views = $ this -> getViews ( ) ; foreach ( $ views as $ view ) { $ info = $ db -> createCommand ( "SHOW CREATE VIEW `$view`" ) -> queryAll ( ) ; $ sql = $ info [ 0 ] [ 'Create View' ] ; preg_match ( "/.*VIEW `$view` as (.*)/i" , $ sql , $ match ) ; if ( isset ( $ match [ 1 ] ) ) { $ db -> createCommand ( "CREATE OR REPLACE VIEW `$view` AS " . $ match [ 1 ] ) -> execute ( ) ; Console :: printColor ( "View `$view` was recreated." , "green" ) ; } else { Console :: printColor ( "Cannot find create string for view `$view`." , "red" ) ; } } }
List all views. This method is needed in order to match the database collection if it was changed.
List all views . This method is needed in order to match the database collection if it was changed .