From 628313a734a96d431a036fb1ba58607f74764d24 Mon Sep 17 00:00:00 2001 From: Joe Green Date: Wed, 12 Feb 2014 17:36:24 +0000 Subject: [PATCH] Some hotfixes --- src/Smrtr/MysqlVersionControl/DbConfig.php | 6 +++--- src/Smrtr/MysqlVersionControl/UpCommand.php | 8 ++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Smrtr/MysqlVersionControl/DbConfig.php b/src/Smrtr/MysqlVersionControl/DbConfig.php index 4afa128..056a85f 100644 --- a/src/Smrtr/MysqlVersionControl/DbConfig.php +++ b/src/Smrtr/MysqlVersionControl/DbConfig.php @@ -31,7 +31,7 @@ public static function getPDO($env, $buildtime = false) $config = self::getConfig($env); $config = $config[$key]; - $dsn = sprintf('mysql:host=%s;dbname=%s', $config['host'], $config['dbname']); + $dsn = sprintf('mysql:host=%s;dbname=%s', $config['host'], $config['database']); $db = new \PDO($dsn, $config['user'], $config['password']); return $db; @@ -58,8 +58,8 @@ protected static function getConfigFile() protected static function getProjectPath() { - $parts = explode('/vendor', __FILE__); + $parts = explode('vendor', __FILE__); array_pop($parts); - return implode('/vendor', $parts); + return trim(implode('vendor', $parts), '/\\'); } } diff --git a/src/Smrtr/MysqlVersionControl/UpCommand.php b/src/Smrtr/MysqlVersionControl/UpCommand.php index 6f9a8a1..db868ff 100644 --- a/src/Smrtr/MysqlVersionControl/UpCommand.php +++ b/src/Smrtr/MysqlVersionControl/UpCommand.php @@ -71,14 +71,12 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($buildConf->query("SHOW TABLES LIKE 'db_config'")->rowCount()) { $output->writeln('Database version control is already installed.'); - self::$checkList['db-schema'] = true; - return true; } else { $output->writeln('Installing version control...'); - $result = $buildConf->query( + $result = $buildConf->prepare( "CREATE TABLE `db_config` ( `key` VARCHAR(50) COLLATE 'utf8_general_ci' NOT NULL, @@ -88,8 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output) PRIMARY KEY (`key`), UNIQUE INDEX `db_config_U_1` (`key`) ) ENGINE=MyISAM;" - ) - ->execute(); + )->execute(); if (!$result) { $output->writeln('Installing version control failed.'); @@ -234,7 +231,6 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($result) { $output->writeln('Database updates installed successfully.'); - self::$checkList['db-update'] = true; return true; } else {