o.moresis
2 years ago
6 changed files with 42 additions and 7 deletions
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
<?php |
||||
use MSFD\Services\PgSql; |
||||
|
||||
$user_id = $_SESSION['user_id']; |
||||
|
||||
$db = new PgSql(); |
||||
|
||||
$sql_fetch = "SELECT uuid, request_timestamp as requested_at, attributes->0->>'critId'::text as criteria_ids, status, downloadable FROM webapp.requests |
||||
WHERE user_uuid = '${user_id}' ORDER BY request_timestamp"; |
||||
$rows = $db->getRows($sql_fetch); |
||||
foreach($rows as $row) { |
||||
if (!empty($row->criteria_ids)) { |
||||
$sql_crits = "SELECT code FROM criterias WHERE id IN ({$row->criteria_ids})"; |
||||
$criterias = implode(',', $db->getColValues($sql_crits)); |
||||
$row->criterias = $criterias; |
||||
} else { |
||||
$row->criterias = ''; |
||||
} |
||||
} |
||||
$result = json_encode($rows); |
||||
echo $result; |
Loading…
Reference in new issue