Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT id, author, created, forum, isEdited, message, parent, thread, slug, path FROM posts
- WHERE thread = $1 AND
- (($2 AND NOT $5 AND created >= $3) OR
- ($2 AND $5 AND created <= $3) OR
- (NOT $2 AND NOT $5 AND $4 > 0 AND path > (SELECT path FROM posts WHERE id = $4) AND
- substring(path from 1 for 6) in (select path from posts where parent = 0 and path > (SELECT path FROM posts WHERE id = $4) LIMIT $6)) OR
- (NOT $2 AND $5 AND $4 > 0 AND path < (SELECT path FROM posts WHERE id = $4)) OR
- (NOT $2 AND $4 = 0 AND path <= (SELECT MAX(b.path) || '999999' from (SELECT path from posts where parent = 0 ORDER BY PATH LIMIT $6) b)::text ))
- ORDER BY
- CASE WHEN NOT $5 THEN path END,
- CASE WHEN $5 THEN substring(path from 1 for 6) END DESC, path
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement