update_020500.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. if (!$database->query("SELECT `sysstamp` FROM `lychee_albums` LIMIT 1;")) {
  22. $result = $database->query("ALTER TABLE `lychee_albums` ADD `sysstamp` INT(11) DEFAULT NULL");
  23. if (!$result) return false;
  24. }
  25. if ($database->query("SELECT `sysdate` FROM `lychee_albums` LIMIT 1;")) {
  26. $result = $database->query("SELECT `id`, `sysdate` FROM `lychee_albums`;");
  27. if (!$result) return false;
  28. while ($album = $result->fetch_object()) {
  29. $sysstamp = strtotime($album->sysdate);
  30. $database->query("UPDATE `lychee_albums` SET `sysstamp` = '$sysstamp' WHERE `id` = '$album->id';");
  31. }
  32. $result = $database->query("ALTER TABLE `lychee_albums` DROP COLUMN `sysdate`;");
  33. }
  34. $result = $database->query("UPDATE lychee_settings SET value = '020500' WHERE `key` = 'version';");
  35. if (!$result) return false;
  36. ?>