Update get_user_messages.php

This commit is contained in:
Lizandro Guarnizo
2026-01-24 08:52:34 -05:00
parent 98ef08a409
commit 0900b9e63e
+5 -3
View File
@@ -66,11 +66,13 @@ try {
$params = ['user_id' => $userId];
if ($before) {
$sql .= " AND (c.created_at < :before";
$params['before'] = $before;
$sql .= " AND (c.created_at < :before_lt";
$params['before_lt'] = $before;
if ($beforeId) {
// Incluir mensajes con mismo timestamp pero id menor (paginación estable)
$sql .= " OR (c.created_at = :before AND c.id < :before_id)";
// Usamos placeholder distinto para evitar duplicar el mismo nombre en la query
$sql .= " OR (c.created_at = :before_eq AND c.id < :before_id)";
$params['before_eq'] = $before;
$params['before_id'] = $beforeId;
}
$sql .= ")";