Version 1.2.2: bad SQL query in getImageRotation()

The current query method is this:
`
$result = query_single_row('
SELECT EXIFOrientation
FROM '.prefix('images').' AS i, '.prefix('albums').' AS a
WHERE i.albumid = a.id');
`
which returns all EXIFOrientation entries, then selects the first. Since the unique image ID does not appear to be available to this function, I have passed $imgfile containing the full file path. Then queried based on $imgfile containing the album directory and image filename.

`
function getImageRotation($imgfile) {
$result = query_single_row('
SELECT EXIFOrientation
FROM '.prefix('images').' AS i
JOIN '.prefix('albums').' as a
ON i.albumid = a.id
WHERE "'.$imgfile.'" LIKE CONCAT("%",a.folder,"/",i.filename)');
`
This should return a unique result.

Disclaimer: I'm no pro so some of this may be wrong.

-Luke

Comments

Sign In or Register to comment.