diff options
| author | 2014-01-04 14:34:33 +0100 | |
|---|---|---|
| committer | 2014-01-04 14:34:33 +0100 | |
| commit | 875eaabb77f14e80dd9da6b9daf21eec0af8b50b (patch) | |
| tree | 88994ac2e32c33d1b8f93d7ae2d983abd4356545 | |
| parent | ba87ab061469d30a5879377d63baa92e9a592f63 (diff) | |
| parent | e38b3a9c1bf6b5dd6b9a39fa8947c4475923caf3 (diff) | |
Merge remote-tracking branch 'origin/dev' into beta
| -rw-r--r-- | app/sql.php | 2 | ||||
| -rw-r--r-- | p/i/install.php | 17 |
2 files changed, 10 insertions, 9 deletions
diff --git a/app/sql.php b/app/sql.php index 5a28858a7..1b43da30a 100644 --- a/app/sql.php +++ b/app/sql.php @@ -53,7 +53,7 @@ CREATE TABLE IF NOT EXISTS `%1$sentry` ( ) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB; -INSERT INTO `%1$scategory` (name) VALUES(:catName); +INSERT IGNORE INTO `%1$scategory` (id, name) VALUES(1, :catName); '); define('SQL_DROP_TABLES', 'DROP TABLES %1$sentry, %1$sfeed, %1$scategory'); diff --git a/p/i/install.php b/p/i/install.php index 3316d222b..6891006fa 100644 --- a/p/i/install.php +++ b/p/i/install.php @@ -12,7 +12,7 @@ if (isset ($_GET['step'])) { define ('STEP', 1); } -define('SQL_CREATE_DB', 'CREATE DATABASE %1$s DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); +define('SQL_CREATE_DB', 'CREATE DATABASE IF NOT EXISTS %1$s DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); include(APP_PATH . '/sql.php'); @@ -556,12 +556,13 @@ function checkBD () { PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8' ); - // on ouvre une connexion juste pour créer la base si elle n'existe pas - $str = 'mysql:host=' . $_SESSION['bd_host'] . ';'; - $c = new PDO ($str, $_SESSION['bd_user'], $_SESSION['bd_password'], $driver_options); - - $sql = sprintf (SQL_CREATE_DB, $_SESSION['bd_base']); - $res = $c->query ($sql); + try { // on ouvre une connexion juste pour créer la base si elle n'existe pas + $str = 'mysql:host=' . $_SESSION['bd_host'] . ';'; + $c = new PDO ($str, $_SESSION['bd_user'], $_SESSION['bd_password'], $driver_options); + $sql = sprintf (SQL_CREATE_DB, $_SESSION['bd_base']); + $res = $c->query ($sql); + } catch (PDOException $e) { + } // on écrase la précédente connexion en sélectionnant la nouvelle BDD $str = 'mysql:host=' . $_SESSION['bd_host'] . ';dbname=' . $_SESSION['bd_base']; @@ -590,7 +591,7 @@ function checkBD () { ); $ok = $stm->execute($values); } catch (PDOException $e) { - $error = true; + $ok = false; } if (!$ok) { |
