30
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-06-09 09:42:24 +00:00

Merge pull request #1 from bembelimen/patch-1

Cleaned up the installer script
This commit is contained in:
zero-24 2015-04-03 21:23:45 +02:00
commit fe68e6cca0

View File

@ -78,28 +78,23 @@ class Com_WeblinksInstallerScript
*/ */
function postflight($type, $parent) function postflight($type, $parent)
{ {
$tasks = array( $oldColumns = array(
'0' => 'sid', 'sid',
'1' => 'date', 'date',
'2' => 'archived', 'archived',
'3' => 'approved', 'approved',
); );
$db = JFactory::getDbo(); $db = JFactory::getDbo();
$table = $db->getTableColumns('#__weblinks'); $table = $db->getTableColumns('#__weblinks');
foreach ($tasks as $column) $columns = array_intersect($oldColumns, array_keys($table));
foreach ($columns as $column)
{ {
foreach ($table as $columName => $columType) $sql = 'ALTER TABLE ' . $db->qn('#__weblinks') . ' DROP COLUMN ' . $db->qn($column);
{ $db->setQuery($sql);
if ($columName == $column) $db->execute();
{
$sql = "ALTER TABLE `#__weblinks` DROP COLUMN `" . $column . "`";
$db->clean();
$db->setQuery($sql);
$db->execute();
}
}
} }
} }
} }