30
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-06-18 05:52:22 +00:00

Cleaned up the installer script

- Quoted the table name correctly
- Used some shortcuts
This commit is contained in:
bembelimen 2015-04-03 21:22:26 +02:00
parent 5d3877b9c1
commit 088e19514a

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();
}
}
} }
} }
} }