changed sql for photo table from to avoid memory issues on large photo tables

This commit is contained in:
gerhard6380 2017-05-05 22:29:25 +02:00
parent 38f476eedb
commit 877ecf6d04
1 changed files with 5 additions and 5 deletions

View File

@ -3352,7 +3352,7 @@ $called_api = null;
throw new BadRequestException("no new albumname specified"); throw new BadRequestException("no new albumname specified");
} }
// check if album is existing // check if album is existing
$r = q("SELECT * FROM `photo` WHERE `uid` = %d AND `album` = '%s'", $r = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `album` = '%s'",
intval(api_user()), intval(api_user()),
dbesc($album)); dbesc($album));
if (!dbm::is_result($r)) { if (!dbm::is_result($r)) {
@ -3460,7 +3460,7 @@ $called_api = null;
$mode = "update"; $mode = "update";
// check if photo is existing in database // check if photo is existing in database
$r = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' AND `album` = '%s'", $r = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' AND `album` = '%s'",
intval(api_user()), intval(api_user()),
dbesc($photo_id), dbesc($photo_id),
dbesc($album)); dbesc($album));
@ -3580,7 +3580,7 @@ $called_api = null;
throw new BadRequestException("no photo_id specified"); throw new BadRequestException("no photo_id specified");
} }
// check if photo is existing in database // check if photo is existing in database
$r = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'", $r = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'",
intval(api_user()), intval(api_user()),
dbesc($photo_id) dbesc($photo_id)
); );
@ -3659,7 +3659,7 @@ $called_api = null;
// check if specified profile id is valid // check if specified profile id is valid
if ($profileid != 0) { if ($profileid != 0) {
$r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d", $r = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `id` = %d",
intval(api_user()), intval(api_user()),
intval($profileid)); intval($profileid));
// error message if specified profile id is not in database // error message if specified profile id is not in database
@ -3706,7 +3706,7 @@ $called_api = null;
intval(local_user()) intval(local_user())
); );
} else { } else {
$r = q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d", $r = q("UPDATE `profile` SET `photo` = '%s', `thumb` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc(App::get_baseurl() . '/photo/' . $data['photo']['id'] . '-4.' . $filetype), dbesc(App::get_baseurl() . '/photo/' . $data['photo']['id'] . '-4.' . $filetype),
dbesc(App::get_baseurl() . '/photo/' . $data['photo']['id'] . '-5.' . $filetype), dbesc(App::get_baseurl() . '/photo/' . $data['photo']['id'] . '-5.' . $filetype),
intval($_REQUEST['profile']), intval($_REQUEST['profile']),