Sfoglia il codice sorgente

SQL : Passe e.id en bigint plutôt que char(6)

Contribue à https://github.com/marienfressinaud/FreshRSS/issues/202
e.id est généré à l'insertion par microtime(true).
Alexandre Alapetite 12 anni fa
parent
commit
4355d8447f
2 ha cambiato i file con 6 aggiunte e 10 eliminazioni
  1. 4 8
      app/models/Entry.php
  2. 2 2
      public/install.php

+ 4 - 8
app/models/Entry.php

@@ -2,7 +2,7 @@
 
 
 class Entry extends Model {
 class Entry extends Model {
 
 
-	private $id = null;
+	private $id = 0;
 	private $guid;
 	private $guid;
 	private $title;
 	private $title;
 	private $author;
 	private $author;
@@ -29,11 +29,7 @@ class Entry extends Model {
 	}
 	}
 
 
 	public function id () {
 	public function id () {
-		if(is_null($this->id)) {
-			return small_hash ($this->guid . Configuration::selApplication ());
-		} else {
-			return $this->id;
-		}
+		return $this->id;
 	}
 	}
 	public function guid () {
 	public function guid () {
 		return $this->guid;
 		return $this->guid;
@@ -195,11 +191,11 @@ class Entry extends Model {
 
 
 class EntryDAO extends Model_pdo {
 class EntryDAO extends Model_pdo {
 	public function addEntry ($valuesTmp) {
 	public function addEntry ($valuesTmp) {
-		$sql = 'INSERT INTO ' . $this->prefix . 'entry(id, guid, title, author, content, link, date, is_read, is_favorite, id_feed, tags) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
+		$sql = 'INSERT INTO ' . $this->prefix . 'entry(id, guid, title, author, content, link, date, is_read, is_favorite, id_feed, tags) VALUES(CAST(? * 1000000 AS SIGNED INTEGER), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
 		$stm = $this->bd->prepare ($sql);
 		$stm = $this->bd->prepare ($sql);
 
 
 		$values = array (
 		$values = array (
-			$valuesTmp['id'],
+			microtime(true),
 			substr($valuesTmp['guid'], 0, 760),
 			substr($valuesTmp['guid'], 0, 760),
 			substr($valuesTmp['title'], 0, 255),
 			substr($valuesTmp['title'], 0, 255),
 			substr($valuesTmp['author'], 0, 255),
 			substr($valuesTmp['author'], 0, 255),

+ 2 - 2
public/install.php

@@ -44,7 +44,7 @@ define ('SQL_REQ_FEED', 'CREATE TABLE IF NOT EXISTS `%sfeed` (
 ) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
 ) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
 
 
 define ('SQL_REQ_ENTRY', 'CREATE TABLE IF NOT EXISTS `%sentry` (
 define ('SQL_REQ_ENTRY', 'CREATE TABLE IF NOT EXISTS `%sentry` (
-  `id` char(6) NOT NULL,
+  `id` bigint NOT NULL,	-- v0.7
   `guid` varchar(760) CHARACTER SET latin1 NOT NULL,	-- Maximum for UNIQUE is 767B
   `guid` varchar(760) CHARACTER SET latin1 NOT NULL,	-- Maximum for UNIQUE is 767B
   `title` varchar(255) NOT NULL,
   `title` varchar(255) NOT NULL,
   `author` varchar(255) NOT NULL,
   `author` varchar(255) NOT NULL,
@@ -60,7 +60,7 @@ define ('SQL_REQ_ENTRY', 'CREATE TABLE IF NOT EXISTS `%sentry` (
   UNIQUE KEY (`id_feed`,`guid`),	-- v0.7
   UNIQUE KEY (`id_feed`,`guid`),	-- v0.7
   INDEX (`is_favorite`),	-- v0.7
   INDEX (`is_favorite`),	-- v0.7
   INDEX (`is_read`),	-- v0.7
   INDEX (`is_read`),	-- v0.7
-  INDEX (`date`)	-- v0.7	//TODO: remove after https://github.com/marienfressinaud/FreshRSS/issues/202
+  INDEX (`date`)	-- v0.7	//Consider removing after https://github.com/marienfressinaud/FreshRSS/issues/202
 ) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
 ) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;');