FIx: some queries fail with prefixed table names

This commit is contained in:
Bartek Fabiszewski 2017-04-18 19:43:46 +02:00
parent ffef321be9
commit e11c000722

View File

@ -56,8 +56,8 @@
p.latitude, p.longitude, p.altitude, p.speed, p.bearing, p.accuracy, p.provider, p.latitude, p.longitude, p.altitude, p.speed, p.bearing, p.accuracy, p.provider,
p.comment, p.image_id, u.login, t.name p.comment, p.image_id, u.login, t.name
FROM `" . self::$db->table('positions') . "` p FROM `" . self::$db->table('positions') . "` p
LEFT JOIN users u ON (p.user_id = u.id) LEFT JOIN `" . self::$db->table('users') . "` u ON (p.user_id = u.id)
LEFT JOIN tracks t ON (p.track_id = t.id) LEFT JOIN `" . self::$db->table('tracks') . "` t ON (p.track_id = t.id)
WHERE id = ? LIMIT 1"; WHERE id = ? LIMIT 1";
$params = [ 'i', $positionId ]; $params = [ 'i', $positionId ];
$this->loadWithQuery($query, $params); $this->loadWithQuery($query, $params);
@ -151,8 +151,8 @@
p.latitude, p.longitude, p.altitude, p.speed, p.bearing, p.accuracy, p.provider, p.latitude, p.longitude, p.altitude, p.speed, p.bearing, p.accuracy, p.provider,
p.comment, p.image_id, u.login, t.name p.comment, p.image_id, u.login, t.name
FROM `" . self::$db->table('positions') . "` p FROM `" . self::$db->table('positions') . "` p
LEFT JOIN users u ON (p.user_id = u.id) LEFT JOIN `" . self::$db->table('users') . "` u ON (p.user_id = u.id)
LEFT JOIN tracks t ON (p.track_id = t.id) LEFT JOIN `" . self::$db->table('tracks') . "` t ON (p.track_id = t.id)
$where $where
ORDER BY p.time DESC LIMIT 1"; ORDER BY p.time DESC LIMIT 1";
$this->loadWithQuery($query, $params); $this->loadWithQuery($query, $params);
@ -183,8 +183,8 @@
p.latitude, p.longitude, p.altitude, p.speed, p.bearing, p.accuracy, p.provider, p.latitude, p.longitude, p.altitude, p.speed, p.bearing, p.accuracy, p.provider,
p.comment, p.image_id, u.login, t.name p.comment, p.image_id, u.login, t.name
FROM `" . self::$db->table('positions') . "` p FROM `" . self::$db->table('positions') . "` p
LEFT JOIN users u ON (p.user_id = u.id) LEFT JOIN `" . self::$db->table('users') . "` u ON (p.user_id = u.id)
LEFT JOIN tracks t ON (p.track_id = t.id) LEFT JOIN `" . self::$db->table('tracks') . "` t ON (p.track_id = t.id)
$where $where
ORDER BY p.time"; ORDER BY p.time";
$result = self::$db->query($query); $result = self::$db->query($query);