Update script.php

This commit is contained in:
zero-24 2015-04-01 23:12:10 +02:00
parent f8e87d5689
commit 52ae52e1ba
1 changed files with 35 additions and 0 deletions

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