update_020100.php 1.4 KB

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