MySQL select performance (#79)
This commit is contained in:
parent
fda195f6fd
commit
759ce874e7
@ -31,8 +31,8 @@ function getAlbums($public) {
|
||||
if (!$public) $return = getSmartInfo();
|
||||
|
||||
// Albums
|
||||
if ($public) $query = "SELECT * FROM lychee_albums WHERE public = 1";
|
||||
else $query = "SELECT * FROM lychee_albums";
|
||||
if ($public) $query = "SELECT id, title, public, sysdate, password FROM lychee_albums WHERE public = 1";
|
||||
else $query = "SELECT id, title, public, sysdate, password FROM lychee_albums";
|
||||
|
||||
$result = $database->query($query) OR exit("Error: $result <br>".$database->error);
|
||||
$i = 0;
|
||||
@ -243,15 +243,15 @@ function getAlbumArchive($albumID) {
|
||||
|
||||
switch($albumID) {
|
||||
case 's':
|
||||
$query = "SELECT * FROM lychee_photos WHERE public = '1';";
|
||||
$query = "SELECT url FROM lychee_photos WHERE public = '1';";
|
||||
$zipTitle = "Public";
|
||||
break;
|
||||
case 'f':
|
||||
$query = "SELECT * FROM lychee_photos WHERE star = '1';";
|
||||
$query = "SELECT url FROM lychee_photos WHERE star = '1';";
|
||||
$zipTitle = "Starred";
|
||||
break;
|
||||
default:
|
||||
$query = "SELECT * FROM lychee_photos WHERE album = '$albumID';";
|
||||
$query = "SELECT url FROM lychee_photos WHERE album = '$albumID';";
|
||||
$zipTitle = "Unsorted";
|
||||
}
|
||||
|
||||
@ -265,7 +265,7 @@ function getAlbumArchive($albumID) {
|
||||
$i++;
|
||||
}
|
||||
|
||||
$result = $database->query("SELECT * FROM lychee_albums WHERE id = '$albumID';");
|
||||
$result = $database->query("SELECT title FROM lychee_albums WHERE id = '$albumID' LIMIT 1;");
|
||||
$row = $result->fetch_object();
|
||||
if ($albumID!=0&&is_numeric($albumID)) $zipTitle = $row->title;
|
||||
$filename = "../data/$zipTitle.zip";
|
||||
|
@ -16,7 +16,7 @@ function openGraphHeader($photoID) {
|
||||
$photoID = mysqli_real_escape_string($database, $photoID);
|
||||
if (!is_numeric($photoID)) return false;
|
||||
|
||||
$result = $database->query("SELECT * FROM lychee_photos WHERE id = '$photoID';");
|
||||
$result = $database->query("SELECT title, description, url FROM lychee_photos WHERE id = '$photoID';");
|
||||
$row = $result->fetch_object();
|
||||
|
||||
$parseUrl = parse_url("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
|
||||
@ -54,7 +54,7 @@ function search($term) {
|
||||
}
|
||||
|
||||
// Albums
|
||||
$result = $database->query("SELECT * FROM lychee_albums WHERE title like '%$term%' OR description like '%$term%';");
|
||||
$result = $database->query("SELECT id, title, public, sysdate, password FROM lychee_albums WHERE title like '%$term%' OR description like '%$term%';");
|
||||
$i = 0;
|
||||
while($row = $result->fetch_object()) {
|
||||
|
||||
|
@ -132,7 +132,7 @@ function deletePhoto($photoIDs) {
|
||||
|
||||
global $database;
|
||||
|
||||
$result = $database->query("SELECT * FROM lychee_photos WHERE id IN ($photoIDs);");
|
||||
$result = $database->query("SELECT id, url, thumbUrl FROM lychee_photos WHERE id IN ($photoIDs);");
|
||||
|
||||
while ($row = $result->fetch_object()) {
|
||||
|
||||
@ -160,12 +160,11 @@ function isPhotoPublic($photoID, $password) {
|
||||
|
||||
global $database;
|
||||
|
||||
$query = "SELECT * FROM lychee_photos WHERE id = '$photoID';";
|
||||
$query = "SELECT public, album FROM lychee_photos WHERE id = '$photoID';";
|
||||
|
||||
$result = $database->query($query);
|
||||
$row = $result->fetch_object();
|
||||
|
||||
if (!is_numeric($photoID)&&!$row) return true;
|
||||
if ($row->public==1) return true;
|
||||
else {
|
||||
$cAP = checkAlbumPassword($row->album, $password);
|
||||
@ -180,7 +179,7 @@ function getPhotoArchive($photoID) {
|
||||
|
||||
global $database;
|
||||
|
||||
$result = $database->query("SELECT * FROM lychee_photos WHERE id = '$photoID';");
|
||||
$result = $database->query("SELECT title, url FROM lychee_photos WHERE id = '$photoID';");
|
||||
$row = $result->fetch_object();
|
||||
|
||||
$extension = array_reverse(explode('.', $row->url));
|
||||
|
Loading…
Reference in New Issue
Block a user