我有一个注释表,其中包含以下字段以及一些其他字段(如created_at和updated_at):
+====+=========+========+========+
| id | post_id | author | parent |
+====+=========+========+========+
| 1 | 5 | 1 | 0 |
+----+---------+--------+--------+
| 2 | 5 | 5 | 1 |
+----+---------+--------+--------+
| 3 | 5 | 1 | 0 |
+----+---------+--------+--------+
| 4 | 5 | 7 | 1 |
+----+---------+--------+--------+
| 5 | 5 | 1 | 4 |
+----+---------+--------+--------+
| 6 | 5 | 3 | 0 |
+----+---------+--------+--------+
| 7 | 5 | 5 | 4 |
+----+---------+--------+--------+
| 8 | 5 | 3 | 1 |
+----+---------+--------+--------+
| 9 | 5 | 1 | 0 |
+----+---------+--------+--------+
| 10 | 5 | 7 | 6 |
+----+---------+--------+--------+
| 11 | 5 | 3 | 6 |
+----+---------+--------+--------+
| 12 | 5 | 3 | 4 |
+----+---------+--------+--------+
| 13 | 5 | 1 | 4 |
+----+---------+--------+--------+
分页过程将使用Ajax完成,我想创建一个分页,其中每页的注释等于6,页面1将只包含图像中的前6个注释(从comment_id = 1到comment_id = 12)将是load more comments
按钮(如Disqus),当它们点击它时将出现在注释id = 12的底部,然后将加载下面的6条注释等等,我只想要SQL和PHP代码。
我希望SQL语句尽可能高效,如果它们能使选择过程更有效,我不介意创建其他表。
提前谢谢