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