mirror of
https://github.com/joomla-extensions/weblinks.git
synced 2024-09-27 20:49:05 +00:00
Cleaned up the installer script
- Quoted the table name correctly - Used some shortcuts
This commit is contained in:
parent
5d3877b9c1
commit
088e19514a
@ -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);
|
||||||
{
|
|
||||||
if ($columName == $column)
|
|
||||||
{
|
|
||||||
$sql = "ALTER TABLE `#__weblinks` DROP COLUMN `" . $column . "`";
|
|
||||||
$db->clean();
|
|
||||||
$db->setQuery($sql);
|
$db->setQuery($sql);
|
||||||
$db->execute();
|
$db->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user