22 lines
928 B
PHP
22 lines
928 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
$host = '10.1.0.3'; $port = '5432'; $db = 'adx_system'; $user = 'admin'; $pass = 'admin123';
|
|
$pdo = null;
|
|
try {
|
|
$pdo = new PDO("pgsql:host=$host;port=$port;dbname=$db", $user, $pass);
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
} catch (Exception $e) {
|
|
echo json_encode(['ok'=>false,'error'=>$e->getMessage()]); exit;
|
|
}
|
|
|
|
$rows = $pdo->query("SELECT pays, COUNT(*) AS c FROM ethica.medecins_real GROUP BY pays ORDER BY c DESC")->fetchAll(PDO::FETCH_ASSOC);
|
|
$total = array_sum(array_column($rows, 'c'));
|
|
echo json_encode([
|
|
'ok' => true,
|
|
'ts' => date('c'),
|
|
'table' => 'ethica.medecins_real',
|
|
'total_hcps' => (int)$total,
|
|
'by_country' => array_map(fn($r)=>['pays'=>$r['pays'] ?: 'UNKNOWN','count'=>(int)$r['c'],'pct'=>round($r['c']*100/max(1,$total),1)], $rows),
|
|
'summary' => count($rows) . ' pays'
|
|
], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|