[pLog-svn] r3935 - plog/trunk
pwestbro at devel.lifetype.net
pwestbro at devel.lifetype.net
Tue Sep 5 06:14:53 GMT 2006
Author: pwestbro
Date: 2006-09-05 06:14:52 +0000 (Tue, 05 Sep 2006)
New Revision: 3935
Modified:
plog/trunk/wizard.php
Log:
Fixed bug 1029
Now removing duplicates from the config table, in the upgrade wizard, works with mysql 3.23
Modified: plog/trunk/wizard.php
===================================================================
--- plog/trunk/wizard.php 2006-09-03 19:19:58 UTC (rev 3934)
+++ plog/trunk/wizard.php 2006-09-05 06:14:52 UTC (rev 3935)
@@ -1389,23 +1389,29 @@
$result->Close();
// remove all duplicates in plog_config table
- $query = "DELETE a FROM ".$this->_dbPrefix."config a LEFT JOIN ".$this->_dbPrefix."config b ".
- "ON a.config_key = b.config_key WHERE a.id > b.id ";
-
+
+ // first create temp table without the duplicates
+ $query = "CREATE TEMPORARY TABLE tmptable ".
+ "SELECT * FROM ".$this->_dbPrefix."config WHERE 1 GROUP BY config_key";
$result = $this->_db->Execute($query);
- if(!$result){
- // On 4.0, the above query won't work, so let's try it in 4.0 syntax
- // remove all duplicates in plog_config table
- $query = "DELETE ".$this->_dbPrefix."config FROM ".$this->_dbPrefix."config a ".
- "LEFT JOIN ".$this->_dbPrefix."config b ".
- "ON a.config_key = b.config_key WHERE a.id > b.id ";
+ if($result){
+ $result->Close();
+ // Now delete the old table
+ $query = "DELETE FROM ".$this->_dbPrefix."config";
$result = $this->_db->Execute($query);
- if(!$result){
- $message .= "Error removing duplicates (tried 4.0 and 4.1 syntax) in config table: ".
- $this->_db->ErrorMsg()."<br/>";
- $errors = true;
+ if($result){
+ $result->Close();
+ // Insert the unique rows into the old table
+ $query = "INSERT INTO ".$this->_dbPrefix."config SELECT * FROM tmptable";
+ $result = $this->_db->Execute($query);
}
}
+ if(!$result){
+ $message .= "Error removing duplicates in config table: ".
+ $this->_db->ErrorMsg()."<br/>";
+ $errors = true;
+ }
+
if($result){
// remove index id field, we don't need it any more!
More information about the pLog-svn
mailing list