MAPG-3 select 1 place randomly from places (with demo map id 1)
This commit is contained in:
parent
153acd1a4e
commit
90a0e497b3
@ -2,6 +2,7 @@
|
||||
|
||||
use MapGuesser\Util\Geo\Bounds;
|
||||
use MapGuesser\Util\Geo\Position;
|
||||
use mysqli;
|
||||
|
||||
class GuessController extends BaseController
|
||||
{
|
||||
@ -9,8 +10,20 @@ class GuessController extends BaseController
|
||||
|
||||
protected function operate() : void
|
||||
{
|
||||
// demo position
|
||||
$realPosition = new Position(47.85239, 13.35101);
|
||||
$mysql = new mysqli($_ENV['DB_HOST'], $_ENV['DB_USER'], $_ENV['DB_PASSWORD'], $_ENV['DB_NAME']);
|
||||
|
||||
// demo map
|
||||
$mapId = 1;
|
||||
|
||||
// using RAND() for the time being, could be changed in the future
|
||||
$stmt = $mysql->prepare('SELECT lat, lng FROM places WHERE map_id=? ORDER BY RAND() LIMIT 1');
|
||||
$stmt->bind_param("i", $mapId);
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
|
||||
$realPosition = new Position($row['lat'], $row['lng']);
|
||||
|
||||
// demo bounds
|
||||
$bounds = new Bounds($realPosition);
|
||||
|
Loading…
Reference in New Issue
Block a user