Front + gestion des utilisateurs + affichage indice, tri et creation action
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* =========================================================
|
||||
* API : LECTURE COMPLETE DE LA TABLE indice
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/database.php';
|
||||
|
||||
header(
|
||||
'Content-Type: application/json; charset=utf-8'
|
||||
);
|
||||
|
||||
try {
|
||||
|
||||
/*
|
||||
* Lecture de toute la table
|
||||
*/
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
id,
|
||||
indice,
|
||||
nom,
|
||||
isin,
|
||||
symbole,
|
||||
actif,
|
||||
afficher,
|
||||
updated_at,
|
||||
created_at
|
||||
FROM indice
|
||||
ORDER BY
|
||||
indice ASC,
|
||||
nom ASC
|
||||
";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$data = $stmt->fetchAll();
|
||||
|
||||
|
||||
/*
|
||||
* Réponse JSON
|
||||
*/
|
||||
|
||||
echo json_encode(
|
||||
[
|
||||
'status' => 'success',
|
||||
'count' => count($data),
|
||||
'data' => $data
|
||||
],
|
||||
JSON_UNESCAPED_UNICODE |
|
||||
JSON_UNESCAPED_SLASHES
|
||||
);
|
||||
} catch (PDOException $e) {
|
||||
|
||||
/*
|
||||
* Erreur MySQL
|
||||
*/
|
||||
|
||||
http_response_code(500);
|
||||
|
||||
echo json_encode(
|
||||
[
|
||||
'status' => 'error',
|
||||
'message' => 'Erreur lors de la lecture de la table indice.'
|
||||
],
|
||||
JSON_UNESCAPED_UNICODE
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user