Jelajahi Sumber

SQL : Insère la catégorie par défaut dès la création des tables

Alexandre Alapetite 12 tahun lalu
induk
melakukan
a08201c414
3 mengubah file dengan 10 tambahan dan 2 penghapusan
  1. 4 1
      app/Models/UserDAO.php
  2. 2 0
      app/sql.php
  3. 4 1
      p/i/install.php

+ 4 - 1
app/Models/UserDAO.php

@@ -7,7 +7,10 @@ class FreshRSS_UserDAO extends Minz_ModelPdo {
 
 		$sql = sprintf(SQL_CREATE_TABLES, $db['prefix'] . $username . '_');
 		$stm = $this->bd->prepare($sql, array(PDO::ATTR_EMULATE_PREPARES => true));
-		if ($stm && $stm->execute()) {
+		$values = array(
+			'catName' => Minz_Translate::t('default_category'),
+		);
+		if ($stm && $stm->execute($values)) {
 			return true;
 		} else {
 			$info = $stm->errorInfo();

+ 2 - 0
app/sql.php

@@ -52,6 +52,8 @@ CREATE TABLE IF NOT EXISTS `%1$sentry` (
 	INDEX (`is_read`)	-- v0.7
 ) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci
 ENGINE = INNODB;
+
+INSERT INTO `%1$scategory` (name) VALUES(:catName);
 ');
 
 define('SQL_DROP_TABLES', 'DROP TABLES %1$sentry, %1$sfeed, %1$scategory');

+ 4 - 1
p/i/install.php

@@ -585,7 +585,10 @@ function checkBD () {
 
 		$sql = sprintf(SQL_CREATE_TABLES, $_SESSION['bd_prefix_user']);
 		$stm = $c->prepare($sql, array(PDO::ATTR_EMULATE_PREPARES => true));
-		$ok = $stm->execute();
+		$values = array(
+			'catName' => _t('default_category'),
+		);
+		$ok = $stm->execute($values);
 	} catch (PDOException $e) {
 		$error = true;
 	}