update_020500.php 1.0 KB

12345678910111213141516171819202122232425262728
  1. <?php
  2. ###
  3. # @name Update to version 2.5
  4. # @author Tobias Reich
  5. # @copyright 2014 by Tobias Reich
  6. ###
  7. if (!$database->query("SELECT `takestamp` FROM `lychee_photos` LIMIT 1;")) {
  8. $result = $database->query("ALTER TABLE `lychee_photos` ADD `takestamp` INT(11) DEFAULT NULL");
  9. if (!$result) return false;
  10. }
  11. if ($database->query("SELECT `takedate`, `taketime` FROM `lychee_photos` LIMIT 1;")) {
  12. $result = $database->query("SELECT `id`, `takedate`, `taketime` FROM `lychee_photos` WHERE `takedate` <> '' AND `taketime` <> '';");
  13. if (!$result) return false;
  14. while ($photo = $result->fetch_object()) {
  15. $takestamp = strtotime($photo->takedate . $photo->taketime);
  16. $database->query("UPDATE lychee_photos SET takestamp = '$takestamp' WHERE `id` = '$photo->id';");
  17. }
  18. $result = $database->query("ALTER TABLE `lychee_photos` DROP COLUMN `takedate`;");
  19. $result = $database->query("ALTER TABLE `lychee_photos` DROP COLUMN `taketime`;");
  20. }
  21. $result = $database->query("UPDATE lychee_settings SET value = '020500' WHERE `key` = 'version';");
  22. if (!$result) return false;
  23. ?>