summaryrefslogtreecommitdiffstats
path: root/apis/update.inc.php
diff options
context:
space:
mode:
authorJonathan Bauer2014-06-05 17:37:05 +0200
committerJonathan Bauer2014-06-05 17:37:05 +0200
commit13930eb005050787246994431b515f4bd8b3baf8 (patch)
tree21d0503cd6592ef2a15b73e76d09ebcd4b86b432 /apis/update.inc.php
parentfix news date (diff)
downloadslx-admin-13930eb005050787246994431b515f4bd8b3baf8.tar.gz
slx-admin-13930eb005050787246994431b515f4bd8b3baf8.tar.xz
slx-admin-13930eb005050787246994431b515f4bd8b3baf8.zip
update 3 : news table
Diffstat (limited to 'apis/update.inc.php')
-rw-r--r--apis/update.inc.php32
1 files changed, 29 insertions, 3 deletions
diff --git a/apis/update.inc.php b/apis/update.inc.php
index 4ec94882..bab6bcea 100644
--- a/apis/update.inc.php
+++ b/apis/update.inc.php
@@ -1,6 +1,6 @@
<?php
-$targetVersion = 2;
+$targetVersion = 3;
// #######################
@@ -21,7 +21,7 @@ if (!$function())
$currentVersion++;
-$ret = Database::exec("INSERT INTO property (name, value) VALUES ('webif-version', :version)", array('version' => $currentVersion), true);
+$ret = Database::exec("INSERT INTO property (name, value) VALUES ('webif-version', :version) ON DUPLICATE KEY UPDATE value = VALUES(value)", array('version' => $currentVersion), false);
if ($ret === false)
die('Writing version information back to DB failed. Next update will probably break.');
@@ -41,6 +41,7 @@ function update_1()
{
$res = Database::simpleQuery("DESCRIBE property", array(), false);
$type = false;
+ if ($res === false) return;
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
if ($row['Field'] !== 'dateline') continue;
$type = $row['Type'];
@@ -54,5 +55,30 @@ function update_1()
return true;
}
+// #######################
-// ################ \ No newline at end of file
+// ##### 2014-06-05
+// Add 'news' table to database schema
+function update_2()
+{
+ $res = Database::simpleQuery("show tables", array(), false);
+ $found = false;
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ if ($row['Tables_in_openslx'] !== 'news') continue;
+ $found = true;
+ break;
+ }
+ if ($found === false) {
+ // create table
+ Database::exec("CREATE TABLE `news` (
+ `newsid` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `dateline` int(10) unsigned NOT NULL,
+ `title` varchar(200) DEFAULT NULL,
+ `content` text,
+ PRIMARY KEY (`newsid`),
+ KEY `dateline` (`dateline`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
+ ");
+ }
+ return true;
+} \ No newline at end of file