lychee/php/database/update_020100.php

43 lines
1.6 KiB
PHP
Raw Normal View History

2014-04-05 16:30:24 +00:00
<?php
###
# @name Update to version 2.1
# @author Tobias Reich
# @copyright 2014 by Tobias Reich
###
$query = Database::prepare($database, "SELECT `tags` FROM `?` LIMIT 1", array(LYCHEE_TABLE_PHOTOS));
if(!$database->query($query)) {
$query = Database::prepare($database, "ALTER TABLE `?` ADD `tags` VARCHAR( 1000 ) NULL DEFAULT ''", array(LYCHEE_TABLE_PHOTOS));
$result = $database->query($query);
2014-05-31 10:06:26 +00:00
if (!$result) {
Log::error($database, 'update_020100', __LINE__, 'Could not update database (' . $database->error . ')');
return false;
}
2014-04-05 16:30:24 +00:00
}
$query = Database::prepare($database, "SELECT `key` FROM `?` WHERE `key` = 'dropboxKey' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
2014-04-05 16:30:24 +00:00
if ($result->num_rows===0) {
$query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('dropboxKey', '')", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
2014-05-31 10:06:26 +00:00
if (!$result) {
Log::error($database, 'update_020100', __LINE__, 'Could not update database (' . $database->error . ')');
return false;
}
2014-04-05 16:30:24 +00:00
}
$query = Database::prepare($database, "SELECT `key` FROM `?` WHERE `key` = 'version' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
2014-04-05 16:30:24 +00:00
if ($result->num_rows===0) {
$query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('version', '020100')", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
2014-05-31 10:06:26 +00:00
if (!$result) {
Log::error($database, 'update_020100', __LINE__, 'Could not update database (' . $database->error . ')');
return false;
}
2014-04-05 16:30:24 +00:00
} else {
if (Database::setVersion($database, '020100')===false) return false;
2014-04-05 16:30:24 +00:00
}
?>