MAPG-43 rewrite controllers to use the new DB classes
This commit is contained in:
1 parent
5a41348cc3
commit
a33244fb56
2 files changed
+19
-36
No files matched your search
@@ -1,16 +1,15 @@
|
||||
<?php namespace MapGuesser\Controller;
|
||||
|
||||
use MapGuesser\Database\Query\Select;
|
||||
use MapGuesser\Interfaces\Controller\IController;
|
||||
use MapGuesser\Interfaces\Database\IResultSet;
|
||||
use MapGuesser\Util\Geo\Bounds;
|
||||
use MapGuesser\View\HtmlView;
|
||||
use MapGuesser\View\JsonView;
|
||||
use MapGuesser\Interfaces\View\IView;
|
||||
use mysqli;
|
||||
|
||||
class GameController implements IController
|
||||
{
|
||||
private mysqli $mysql;
|
||||
|
||||
private bool $jsonResponse;
|
||||
|
||||
// demo map
|
||||
@@ -18,8 +17,6 @@ class GameController implements IController
|
||||
|
||||
public function __construct($jsonResponse = false)
|
||||
{
|
||||
$this->mysql = new mysqli($_ENV['DB_HOST'], $_ENV['DB_USER'], $_ENV['DB_PASSWORD'], $_ENV['DB_NAME']);
|
||||
|
||||
$this->jsonResponse = $jsonResponse;
|
||||
}
|
||||
|
||||
@@ -46,10 +43,11 @@ class GameController implements IController
|
||||
|
||||
private function getMapBounds(): Bounds
|
||||
{
|
||||
$stmt = $this->mysql->prepare('SELECT bound_south_lat, bound_west_lng, bound_north_lat, bound_east_lng FROM maps WHERE id=?');
|
||||
$stmt->bind_param("i", $this->mapId);
|
||||
$stmt->execute();
|
||||
$map = $stmt->get_result()->fetch_assoc();
|
||||
$select = new Select(\Container::$dbConnection, 'maps');
|
||||
$select->columns(['bound_south_lat', 'bound_west_lng', 'bound_north_lat', 'bound_east_lng']);
|
||||
$select->whereId($this->mapId);
|
||||
|
||||
$map = $select->execute()->fetch(IResultSet::FETCH_ASSOC);
|
||||
|
||||
$bounds = Bounds::createDirectly($map['bound_south_lat'], $map['bound_west_lng'], $map['bound_north_lat'], $map['bound_east_lng']);
|
||||
|
||||
|
||||
Reference in new issue
Block a user