lychee/php/database/update_020700.php
Tobias Reich 9e42e74b3a ntermediate sized images for small screen devices #67
- Updated version
- Update database
- Write medium to database
- Delete medium on photo delete
- Show medium depending on screen
2014-10-11 16:09:10 +02:00

35 lines
1.2 KiB
PHP

<?php
###
# @name Update to version 2.6.2
# @author Tobias Reich
# @copyright 2014 by Tobias Reich
###
# Add medium to photos
$query = Database::prepare($database, "SELECT `medium` FROM `?` LIMIT 1", array(LYCHEE_TABLE_PHOTOS));
if (!$database->query($query)) {
$query = Database::prepare($database, "ALTER TABLE `?` ADD `medium` TINYINT(1) NOT NULL DEFAULT 0", array(LYCHEE_TABLE_PHOTOS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020700', __LINE__, 'Could not update database (' . $database->error . ')');
return false;
}
}
# Add medium to settings
$query = Database::prepare($database, "SELECT `key` FROM `?` WHERE `key` = 'medium' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if ($result->num_rows===0) {
$query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('medium', '1')", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020700', __LINE__, 'Could not update database (' . $database->error . ')');
return false;
}
}
# Set version
if (Database::setVersion($database, '020700')===false) return false;
?>