|
@@ -24,12 +24,18 @@ class PreviousPost extends Action
|
|
|
':pid' => $post->id,
|
|
|
':tid' => $post->topic_id,
|
|
|
];
|
|
|
- $field = $returnId ? 'id' : 'posted';
|
|
|
- $query = "SELECT p.{$field}
|
|
|
- FROM ::posts AS p
|
|
|
- WHERE p.id < ?i:pid AND p.topic_id=?i:tid
|
|
|
- ORDER BY p.id DESC
|
|
|
- LIMIT 1";
|
|
|
+
|
|
|
+ if ($returnId) {
|
|
|
+ $query = 'SELECT MAX(p.id)
|
|
|
+ FROM ::posts AS p
|
|
|
+ WHERE p.id < ?i:pid AND p.topic_id=?i:tid';
|
|
|
+ } else {
|
|
|
+ $query = 'SELECT p.posted
|
|
|
+ FROM ::posts AS p
|
|
|
+ WHERE p.id < ?i:pid AND p.topic_id=?i:tid
|
|
|
+ ORDER BY p.id DESC
|
|
|
+ LIMIT 1';
|
|
|
+ }
|
|
|
|
|
|
$id = (int) $this->c->DB->query($query, $vars)->fetchColumn();
|
|
|
|