Properly bound join in MySQL and SQLite PHP tile lookup

This commit is contained in:
Mike Primm 2022-03-26 12:44:41 -05:00
parent 93c9ab0b5b
commit 861d1f8606
2 changed files with 2 additions and 2 deletions

View File

@ -81,7 +81,7 @@ if (count($fparts) == 3) { // zoom_x_y
} }
initDbIfNeeded(); initDbIfNeeded();
$stmt = $db->prepare('SELECT t.NewImage,t.Image,t.Format,t.HashCode,t.LastUpdate FROM ' . $dbprefix . 'Maps m JOIN ' . $dbprefix . 'Tiles t WHERE m.WorldID=? AND m.MapID=? AND m.Variant=? AND m.ID=t.MapID AND t.x=? AND t.y=? and t.zoom=?'); $stmt = $db->prepare('SELECT t.NewImage,t.Image,t.Format,t.HashCode,t.LastUpdate FROM ' . $dbprefix . 'Maps m JOIN ' . $dbprefix . 'Tiles t ON m.ID=t.MapID WHERE m.WorldID=? AND m.MapID=? AND m.Variant=? AND t.x=? AND t.y=? and t.zoom=?');
$stmt->bind_param('sssiii', $world, $prefix, $variant, $x, $y, $zoom); $stmt->bind_param('sssiii', $world, $prefix, $variant, $x, $y, $zoom);
$res = $stmt->execute(); $res = $stmt->execute();
$stmt->bind_result($tnewimage, $timage, $format, $thash, $tlast); $stmt->bind_result($tnewimage, $timage, $format, $thash, $tlast);

View File

@ -76,7 +76,7 @@ if (count($fparts) == 3) { // zoom_x_y
$db = new SQLite3($dbfile, SQLITE3_OPEN_READONLY); $db = new SQLite3($dbfile, SQLITE3_OPEN_READONLY);
$stmt = $db->prepare('SELECT Tiles.Image,Tiles.Format,Tiles.HashCode,Tiles.LastUpdate,Tiles.ImageLen FROM Maps JOIN Tiles WHERE Maps.WorldID=:wid AND Maps.MapID=:mapid AND Maps.Variant=:var AND Maps.ID=Tiles.MapID AND Tiles.x=:x AND Tiles.y=:y and Tiles.zoom=:zoom'); $stmt = $db->prepare('SELECT Tiles.Image,Tiles.Format,Tiles.HashCode,Tiles.LastUpdate,Tiles.ImageLen FROM Maps JOIN Tiles ON Maps.ID=Tiles.MapID WHERE Maps.WorldID=:wid AND Maps.MapID=:mapid AND Maps.Variant=:var AND Tiles.x=:x AND Tiles.y=:y and Tiles.zoom=:zoom');
$stmt->bindValue(':wid', $world, SQLITE3_TEXT); $stmt->bindValue(':wid', $world, SQLITE3_TEXT);
$stmt->bindValue(':mapid', $prefix, SQLITE3_TEXT); $stmt->bindValue(':mapid', $prefix, SQLITE3_TEXT);
$stmt->bindValue(':var', $variant, SQLITE3_TEXT); $stmt->bindValue(':var', $variant, SQLITE3_TEXT);