Fix: last position of given user shown incorrectly

This commit is contained in:
Bartek Fabiszewski 2017-04-09 14:03:13 +02:00
parent 4e76aab584
commit 53043c0057

View File

@ -77,15 +77,23 @@ class uPosition {
return $positionId;
}
public function getLast() {
public function getLast($userId = NULL) {
if (!empty($userId)) {
$where = "WHERE p.user_id = ?";
$params = [ 'i', $userId ];
} else {
$where = "";
$params = NULL;
}
$query = "SELECT p.id, p.time, p.user_id, p.track_id,
p.latitude, p.longitude, p.altitude, p.speed, p.bearing, p.accuracy, p.provider,
p.comment, p.image_id, u.login, t.name
FROM positions p
LEFT JOIN users u ON (p.user_id = u.id)
LEFT JOIN tracks t ON (p.track_id = t.id)
$where
ORDER BY p.time DESC LIMIT 1";
$this->loadWithQuery($query);
$this->loadWithQuery($query, $params);
}
public function getAll($userId = NULL, $trackId = NULL) {