aboutsummaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-11-18 23:04:43 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-11-18 23:04:43 +0100
commite2d4f1a7214591a47a46272a7a62e320eea029ce (patch)
treebb028ce493c74247e771c623d0a3f13ca4981ec2 /app/models
parent082246d13f524aa646d5aedf49ae7e3b6c621d6c (diff)
SQL : identifiant entier automatique pour les catégories et les flux
Implémentation de https://github.com/marienfressinaud/FreshRSS/issues/262 La catégorie par défaut à le numéro 1. Les numéros de catégories et de flux sont automatiques (1, 2, 3...) L'installeur semble marcher.
Diffstat (limited to 'app/models')
-rwxr-xr-xapp/models/Category.php17
-rwxr-xr-xapp/models/Entry.php9
-rw-r--r--app/models/Feed.php13
3 files changed, 16 insertions, 23 deletions
diff --git a/app/models/Category.php b/app/models/Category.php
index 6e61b5a0e..1ae324ace 100755
--- a/app/models/Category.php
+++ b/app/models/Category.php
@@ -1,7 +1,7 @@
<?php
class Category extends Model {
- private $id = false;
+ private $id = 0;
private $name;
private $color;
private $nbFeed = -1;
@@ -23,11 +23,7 @@ class Category extends Model {
}
public function id () {
- if (!$this->id) {
- return small_hash ($this->name . time () . Configuration::selApplication ());
- } else {
- return $this->id;
- }
+ return $this->id;
}
public function name () {
return $this->name;
@@ -90,11 +86,10 @@ class Category extends Model {
class CategoryDAO extends Model_pdo {
public function addCategory ($valuesTmp) {
- $sql = 'INSERT INTO ' . $this->prefix . 'category (id, name, color) VALUES(?, ?, ?)';
+ $sql = 'INSERT INTO ' . $this->prefix . 'category (name, color) VALUES(?, ?)';
$stm = $this->bd->prepare ($sql);
$values = array (
- $valuesTmp['id'],
substr($valuesTmp['name'], 0, 255),
substr($valuesTmp['color'], 0, 7),
);
@@ -196,7 +191,7 @@ class CategoryDAO extends Model_pdo {
}
public function getDefault () {
- $sql = 'SELECT * FROM ' . $this->prefix . 'category WHERE id="000000"';
+ $sql = 'SELECT * FROM ' . $this->prefix . 'category WHERE id=1';
$stm = $this->bd->prepare ($sql);
$stm->execute ();
@@ -210,11 +205,11 @@ class CategoryDAO extends Model_pdo {
}
}
public function checkDefault () {
- $def_cat = $this->searchById ('000000');
+ $def_cat = $this->searchById (1);
if ($def_cat === false) {
$cat = new Category (Translate::t ('default_category'));
- $cat->_id ('000000');
+ $cat->_id (1);
$values = array (
'id' => $cat->id (),
diff --git a/app/models/Entry.php b/app/models/Entry.php
index 052e5abff..684b1921a 100755
--- a/app/models/Entry.php
+++ b/app/models/Entry.php
@@ -217,8 +217,12 @@ class EntryDAO extends Model_pdo {
} else {
$info = $stm->errorInfo();
if ((int)($info[0] / 1000) !== 23) { //Filter out "SQLSTATE Class code 23: Constraint Violation" because of expected duplicate entries
- Minz_Log::record ('SQL error ' . $info[0] . ': ' . $info[1] . ' ' . $info[2], Minz_Log::ERROR);
- }
+ Minz_Log::record ('SQL error ' . $info[0] . ': ' . $info[1] . ' ' . $info[2]
+ . ' while adding entry in feed ' . $valuesTmp['id_feed'] . ' with title: ' . $valuesTmp['title'], Minz_Log::ERROR);
+ } /*else {
+ Minz_Log::record ('SQL error ' . $info[0] . ': ' . $info[1] . ' ' . $info[2]
+ . ' while adding entry in feed ' . $valuesTmp['id_feed'] . ' with title: ' . $valuesTmp['title'], Minz_Log::DEBUG);
+ }*/
return false;
}
}
@@ -272,7 +276,6 @@ class EntryDAO extends Model_pdo {
. 'WHERE e.id=?';
$values = array ($is_read ? 1 : 0, $id);
$stm = $this->bd->prepare ($sql);
-
if ($stm && $stm->execute ($values)) {
return $stm->rowCount();
} else {
diff --git a/app/models/Feed.php b/app/models/Feed.php
index 549603664..46ba7bd47 100644
--- a/app/models/Feed.php
+++ b/app/models/Feed.php
@@ -1,9 +1,9 @@
<?php
class Feed extends Model {
- private $id = null;
+ private $id = 0;
private $url;
- private $category = '000000';
+ private $category = 1;
private $nbEntries = -1;
private $nbNotRead = -1;
private $entries = null;
@@ -26,11 +26,7 @@ class Feed extends Model {
}
public function id () {
- if(is_null($this->id)) {
- return small_hash ($this->url . Configuration::selApplication ());
- } else {
- return $this->id;
- }
+ return $this->id;
}
public function url () {
return $this->url;
@@ -323,11 +319,10 @@ class Feed extends Model {
class FeedDAO extends Model_pdo {
public function addFeed ($valuesTmp) {
- $sql = 'INSERT INTO ' . $this->prefix . 'feed (id, url, category, name, website, description, lastUpdate, priority, httpAuth, error, keep_history) VALUES(?, ?, ?, ?, ?, ?, ?, 10, ?, 0, 0)';
+ $sql = 'INSERT INTO ' . $this->prefix . 'feed (url, category, name, website, description, lastUpdate, priority, httpAuth, error, keep_history) VALUES(?, ?, ?, ?, ?, ?, 10, ?, 0, 0)';
$stm = $this->bd->prepare ($sql);
$values = array (
- $valuesTmp['id'],
substr($valuesTmp['url'], 0, 511),
$valuesTmp['category'],
substr($valuesTmp['name'], 0, 255),