Add SSE live updates for bestellungen
This commit is contained in:
@@ -352,3 +352,28 @@ SQL;
|
||||
'next_limit' => min($totalCount, $limit + $pageSize),
|
||||
];
|
||||
}
|
||||
|
||||
function get_sales_order_realtime_snapshot(PDO $pdo, int $limit = 1000): array
|
||||
{
|
||||
$limit = max(1, min(2000, $limit));
|
||||
|
||||
$stmt = $pdo->prepare(
|
||||
'SELECT id, created_at, updated_at
|
||||
FROM public.sales_order
|
||||
ORDER BY updated_at DESC NULLS LAST, id DESC
|
||||
LIMIT :limit'
|
||||
);
|
||||
$stmt->bindValue(':limit', $limit, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
|
||||
$rows = [];
|
||||
foreach ($stmt->fetchAll() as $row) {
|
||||
$rows[] = [
|
||||
'id' => (int) ($row['id'] ?? 0),
|
||||
'created_at' => (string) ($row['created_at'] ?? ''),
|
||||
'updated_at' => (string) ($row['updated_at'] ?? ''),
|
||||
];
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user