prepare( "SELECT cr.id, cr.title, cr.body, cr.department_id FROM canned_responses cr WHERE 1=1{$deptFilter} ORDER BY cr.title" ); $stmt->execute($deptParams); $responses = array_map(fn(array $row) => [ 'id' => (int) $row['id'], 'title' => $row['title'], 'body' => api_plain_text($row['body']), 'departmentId' => $row['department_id'] !== null ? (int) $row['department_id'] : null, ], $stmt->fetchAll()); api_json(['items' => $responses]);