diff --git a/include/db.class.php b/include/db.class.php index 568c0ce..4917ef4 100644 --- a/include/db.class.php +++ b/include/db.class.php @@ -113,11 +113,11 @@ class db function getCurrentPlanes() { - $query = "SELECT UNIX_TIMESTAMP(deliveryTime) as deliveryTime, deliveryTZ, destLat, destLon, destName, UNIX_TIMESTAMP(startTime) as startTime, startTZ, startLon, startLat, startName, color FROM avionpoeme WHERE deliveryTimeServer>NOW() AND public='1'"; + $query = "SELECT idAvion as uid, UNIX_TIMESTAMP(deliveryTime) as deliveryTime, deliveryTZ, destLat, destLon, destName, UNIX_TIMESTAMP(startTime) as startTime, startTZ, startLon, startLat, startName, color FROM avionpoeme WHERE deliveryTimeServer>NOW() AND public='1'"; $this->query($query); $planes = $this->result->fetch_all(MYSQLI_ASSOC); - print json_encode($planes); + return planes; } function getAnthology($page=0) @@ -129,13 +129,15 @@ class db if ($page <= 0) //renvoie le nombre de ligne d'anthologie { print '{"nAnthology":"' . $result["count"] . '","nPages":"' . $n_pages .'"}'; + return $n_pages; }else //renvoie les lignes d'anthologie { if ($page > $n_pages) $page=$n_pages; - $query = "SELECT deliveryTime, deliveryTZ, destName, startTime, startTZ, startName, message FROM avionpoeme WHERE public='1' LIMIT " . ($page-1)*RESULTS_BY_PAGE . "," . RESULTS_BY_PAGE; + $query = "SELECT deliveryTime, deliveryTZ, destName, startTime, startTZ, startName, message FROM avionpoeme WHERE public='1' LIMIT " . ($page-1)*RESULTS_BY_PAGE . "," . RESULTS_BY_PAGE . " ORDER BY startTime ASC"; $this->query($query); $planes = $this->result->fetch_all(MYSQLI_ASSOC); print json_encode($planes, JSON_FORCE_OBJECT); + return $planes; } }