update_020100.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. ###
  3. # @name Update to version 2.1
  4. # @author Tobias Reich
  5. # @copyright 2014 by Tobias Reich
  6. ###
  7. $query = Database::prepare($database, "SELECT `tags` FROM `?` LIMIT 1", [LYCHEE_TABLE_PHOTOS]);
  8. if(!$database->query($query)) {
  9. $query = Database::prepare($database, "ALTER TABLE `?` ADD `tags` VARCHAR( 1000 ) NULL DEFAULT ''", [LYCHEE_TABLE_PHOTOS]);
  10. $result = $database->query($query);
  11. if (!$result) {
  12. Log::error($database, 'update_020100', __LINE__, 'Could not update database (' . $database->error . ')');
  13. return false;
  14. }
  15. }
  16. $query = Database::prepare($database, "SELECT `key` FROM `?` WHERE `key` = 'dropboxKey' LIMIT 1", [LYCHEE_TABLE_SETTINGS]);
  17. $result = $database->query($query);
  18. if ($result->num_rows===0) {
  19. $query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('dropboxKey', '')", [LYCHEE_TABLE_SETTINGS]);
  20. $result = $database->query($query);
  21. if (!$result) {
  22. Log::error($database, 'update_020100', __LINE__, 'Could not update database (' . $database->error . ')');
  23. return false;
  24. }
  25. }
  26. $query = Database::prepare($database, "SELECT `key` FROM `?` WHERE `key` = 'version' LIMIT 1", [LYCHEE_TABLE_SETTINGS]);
  27. $result = $database->query($query);
  28. if ($result->num_rows===0) {
  29. $query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('version', '020100')", [LYCHEE_TABLE_SETTINGS]);
  30. $result = $database->query($query);
  31. if (!$result) {
  32. Log::error($database, 'update_020100', __LINE__, 'Could not update database (' . $database->error . ')');
  33. return false;
  34. }
  35. } else {
  36. $query = Database::prepare($database, "UPDATE ? SET value = '020100' WHERE `key` = 'version'", [LYCHEE_TABLE_SETTINGS]);
  37. $result = $database->query($query);
  38. if (!$result) {
  39. Log::error($database, 'update_020100', __LINE__, 'Could not update database (' . $database->error . ')');
  40. return false;
  41. }
  42. }
  43. ?>