/** * Returns the maximum image id (id of the last image) */ public function getMaxImageId() { return DatabaseConnector::getPurePDO()->query("SELECT MAX(photo_id) FROM animal")->fetch()[0]; }
echo json_encode(["species" => $species->fetch()->asArray(), "habitats" => $habitats->fetch()->asArray(), "sites" => $sites->fetch()->asArray()]); } else { if ($apiParam === "counts") { $counts = new SpeciesCountsQuery(); echo $counts->fetch()->asJSON(); } else { if ($apiParam === "habitat_counts") { $counts = new HabitatCountsQuery(); echo $counts->fetch()->asJSON(); } else { if ($apiParam === "species_sites") { $counts = new ChartStatsQuery(); echo $counts->fetch()->asJSON(); } else { if ($apiParam === "stats") { $db = DatabaseConnector::getPurePDO(); $res = $db->query("SELECT (SELECT COUNT(*) FROM `classified`) AS classificationsCount, \n (SELECT COUNT(DISTINCT species) FROM `classified`) AS speciesCount, \n (SELECT COUNT(DISTINCT photo.site_id) FROM `classified` LEFT JOIN photo ON photo.photo_id = classified.photo_id) AS siteCount,\n (SELECT COUNT(DISTINCT site.habitat_id) FROM `classified`LEFT JOIN photo ON photo.photo_id = classified.photo_id LEFT JOIN site ON photo.site_id = site.site_id) AS habitatCount")->fetch(); print json_encode($res); } else { if ($apiParam === "queries") { $recentQueries = new RecentQueries(); echo $recentQueries->fetch()->asJSON(); } else { error("Invalid action"); } } } } } } }