Kaynağa Gözat

Fix LIMIT OFFSET in sql queries

Makes queries independent of the sql syntax.
Visman 3 yıl önce
ebeveyn
işleme
6992be0691

+ 1 - 1
app/Models/Forum/Forum.php

@@ -434,7 +434,7 @@ class Forum extends DataModel
             FROM ::topics AS t
             WHERE t.forum_id=?i:fid
             ORDER BY t.sticky DESC, {$sortBy}, t.id DESC
-            LIMIT ?i:offset, ?i:rows";
+            LIMIT ?i:rows OFFSET ?i:offset";
 
         $this->idsList = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
 

+ 2 - 2
app/Models/PM/PTopic.php

@@ -374,7 +374,7 @@ class PTopic extends DataModel
             FROM ::pm_posts AS pp
             WHERE pp.topic_id=?i:tid
             ORDER BY pp.id
-            LIMIT ?i:offset, ?i:rows';
+            LIMIT ?i:rows OFFSET ?i:offset';
 
         $list  = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
         $posts = $this->c->pms->loadByIds(Cnst::PPOST, $list);
@@ -425,7 +425,7 @@ class PTopic extends DataModel
             FROM ::pm_posts AS pp
             WHERE pp.topic_id=?i:tid
             ORDER BY pp.id DESC
-            LIMIT 0, ?i:rows';
+            LIMIT ?i:rows';
 
         $list  = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
         $posts = $this->c->pms->loadByIds(Cnst::PPOST, $list);

+ 1 - 1
app/Models/Report/Reports.php

@@ -116,7 +116,7 @@ class Reports extends Manager
             FROM ::reports as r
             WHERE r.zapped!=0
             ORDER BY r.zapped DESC
-            LIMIT 10,1';
+            LIMIT 1 OFFSET 10';
 
         $time = (int) $this->c->DB->query($query)->fetchColumn();
 

+ 2 - 2
app/Models/Topic/Topic.php

@@ -349,7 +349,7 @@ class Topic extends DataModel
             FROM ::posts AS p
             WHERE p.topic_id=?i:tid
             ORDER BY p.id
-            LIMIT ?i:offset, ?i:rows';
+            LIMIT ?i:rows OFFSET ?i:offset';
 
         $list = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);
 
@@ -391,7 +391,7 @@ class Topic extends DataModel
             FROM ::posts AS p
             WHERE p.topic_id=?i:tid
             ORDER BY p.id DESC
-            LIMIT 0, ?i:rows';
+            LIMIT ?i:rows';
 
         $this->idsList = $this->c->DB->query($query, $vars)->fetchAll(PDO::FETCH_COLUMN);