32
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-11-16 01:27:07 +00:00

Update script.php

This commit is contained in:
zero-24 2015-04-01 23:12:10 +02:00
parent f8e87d5689
commit 52ae52e1ba

View File

@ -68,4 +68,39 @@ class Com_WeblinksInstallerScript
$category->rebuildPath($category->id);
}
}
/**
* method to update the component
*
* @return void
*/
function update($parent)
{
$tasks = array(
'0' => 'sid',
'1' => 'date',
'2' => 'archived',
'3' => 'approved',
);
foreach $tasks as $column)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select(*);
$query->from($db->quoteName('information_schema.columns'));
$query->where($db->quoteName('table_name') . ' = '. $db->quote('#__weblinks'));
$query->where($db->quoteName('column_name') . ' = '. $db->quote($column));
$numrows = $query->getNumRows();
$db->clean();
if ($numrows != 0)
{
$sql = "ALTER TABLE `#__weblinks` DROP COLUMN `' . $column . '`";
$db->setQuery($sql);
$db->execute();
}
}
}
}