aboutsummaryrefslogtreecommitdiff
path: root/app/models/Feed.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-04-28 14:18:34 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-04-28 14:18:34 +0200
commit1bee8ad9a7c02c0f53d1f334467cb6d1e5044511 (patch)
tree2d983bea4e2a0f654ede6b74251cf9e83ec0fd39 /app/models/Feed.php
parent57f657c04b89c54e6a6b3995a715acfc84a664a7 (diff)
Flux déplacés de catégories lors de la suppression de la leur (issue #28)
Diffstat (limited to 'app/models/Feed.php')
-rw-r--r--app/models/Feed.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/app/models/Feed.php b/app/models/Feed.php
index 97cbe55d1..e519a91cb 100644
--- a/app/models/Feed.php
+++ b/app/models/Feed.php
@@ -296,6 +296,30 @@ class FeedDAO extends Model_pdo {
}
}
+ public function changeCategory ($idOldCat, $idNewCat) {
+ $catDAO = new CategoryDAO ();
+ $newCat = $catDAO->searchById ($idNewCat);
+ if (!$newCat) {
+ $newCat = $catDAO->getDefault ();
+ }
+
+ $sql = 'UPDATE feed SET category=? WHERE category=?';
+ $stm = $this->bd->prepare ($sql);
+
+ $values = array (
+ $newCat->id (),
+ $idOldCat
+ );
+
+ if ($stm && $stm->execute ($values)) {
+ return true;
+ } else {
+ $info = $stm->errorInfo();
+ Log::record ('SQL error : ' . $info[2], Log::ERROR);
+ return false;
+ }
+ }
+
public function deleteFeed ($id) {
$sql = 'DELETE FROM feed WHERE id=?';
$stm = $this->bd->prepare ($sql);