SF.net SVN: postfixadmin:[452] trunk/upgrade.php
Brought to you by:
christian_boltz,
gingerdog
|
From: <Gin...@us...> - 2008-08-31 14:15:39
|
Revision: 452
http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=452&view=rev
Author: GingerDog
Date: 2008-08-31 14:15:48 +0000 (Sun, 31 Aug 2008)
Log Message:
-----------
upgrade.php: ensure we cope with config table with a prefix; thanks to AldoReset (IRC); see also https://sourceforge.net/tracker/index.php?func=detail&aid=2084937&group_id=191583&atid=937964
Modified Paths:
--------------
trunk/upgrade.php
Modified: trunk/upgrade.php
===================================================================
--- trunk/upgrade.php 2008-08-31 14:03:11 UTC (rev 451)
+++ trunk/upgrade.php 2008-08-31 14:15:48 UTC (rev 452)
@@ -51,12 +51,13 @@
}
+$table = table_by_key('config');
if($CONF['database_type'] == 'pgsql') {
// check if table already exists, if so, don't recreate it
- $r = db_query("SELECT relname FROM pg_class WHERE relname = 'config'");
+ $r = db_query("SELECT relname FROM pg_class WHERE relname = '$table'");
if($r['rows'] == 0) {
$pgsql = "
- CREATE TABLE " . table_by_key ('config') . " (
+ CREATE TABLE $table (
id SERIAL,
name VARCHAR(20) NOT NULL UNIQUE,
value VARCHAR(20) NOT NULL,
@@ -67,7 +68,7 @@
}
else {
$mysql = "
- CREATE TABLE {IF_NOT_EXISTS} " . table_by_key ('config') . "(
+ CREATE TABLE {IF_NOT_EXISTS} $table (
`id` {AUTOINCREMENT} {PRIMARY},
`name` VARCHAR(20) {LATIN1} NOT NULL DEFAULT '',
`value` VARCHAR(20) {LATIN1} NOT NULL DEFAULT '',
@@ -77,7 +78,7 @@
db_query_parsed($mysql, 0, " ENGINE = MYISAM COMMENT = 'PostfixAdmin settings'");
}
-$sql = "SELECT * FROM " . table_by_key ('config') . " WHERE name = 'version'";
+$sql = "SELECT * FROM $table WHERE name = 'version'";
// insert into config('version', '01');
@@ -88,7 +89,7 @@
$row = db_array($rs);
$version = $row['value'];
} else {
- db_query_parsed("INSERT INTO " . table_by_key ('config') . " (name, value) VALUES ('version', '0')", 0, '');
+ db_query_parsed("INSERT INTO $table (name, value) VALUES ('version', '0')", 0, '');
$version = 0;
}
@@ -105,7 +106,7 @@
return true;
}
- echo "<p>Updating database:<p>old version: $current_version; target version: $target_version";
+ echo "<p>Updating database:</p><p>- old version: $current_version; target version: $target_version</p>";
for ($i = $current_version +1; $i <= $target_version; $i++) {
$function = "upgrade_$i";
@@ -131,7 +132,8 @@
}
// Update config table so we don't run the same query twice in the future.
$i = (int) $i;
- $sql = "UPDATE config SET value = $i WHERE name = 'version'";
+ $table = table_by_key('config');
+ $sql = "UPDATE $table SET value = $i WHERE name = 'version'";
db_query($sql);
};
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|