Jake Bunce
Well-known member
This is my install code for my addon:
The red part is supposed to add those columns if they are missing. The try / catch is supposed to let those queries fail gracefully. But one person reported this error on the first try block:
I can't reproduce this error myself and I can't figure out what might be causing it. Any ideas?
Because I can't reproduce this error I am inclined to blame his PHP configuration, but I want to check with you guys first.
Rich (BB code):
public static function install()
{
$db = XenForo_Application::get('db');
$db->query("
CREATE TABLE IF NOT EXISTS `nat_options` (
`node_id` int(10) unsigned NOT NULL,
`nat_display_tab` tinyint(3) unsigned NOT NULL,
`nat_display_tabperms` tinyint(3) unsigned NOT NULL,
`nat_display_order` int(10) unsigned NOT NULL,
`nat_position` enum('home','middle','end') NOT NULL,
`nat_childlinks` tinyint(3) unsigned NOT NULL,
`nat_childlinksperms` tinyint(3) unsigned NOT NULL,
`nat_markread` tinyint(3) unsigned NOT NULL,
`nat_linkstemplate` varchar(50) NOT NULL,
`nat_popup` tinyint(3) unsigned NOT NULL,
`nat_childnodes` text NOT NULL,
`nat_firstchildnodes` mediumblob NOT NULL,
UNIQUE KEY `node_id` (`node_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='NodesAsTabs addon'
");
try
{
$db->query("
ALTER TABLE `nat_options` ADD `nat_markread` tinyint(3) unsigned NOT NULL AFTER `nat_childlinksperms`
");
}
catch (Zend_Db_Exception $e)
{
}
try
{
$db->query("
ALTER TABLE `nat_options` ADD `nat_popup` tinyint(3) unsigned NOT NULL AFTER `nat_linkstemplate`
");
}
catch (Zend_Db_Exception $e)
{
}
$optionsModel = XenForo_Model::create('NodesAsTabs_Model_Options');
$optionsModel->deleteOrphans();
$optionsModel->rebuildCache();
}
The red part is supposed to add those columns if they are missing. The try / catch is supposed to let those queries fail gracefully. But one person reported this error on the first try block:
Problem here version of XF 1.2
Server Error
mysqli_stmt::execute(): (42S21/1060): Duplicate column name 'nat_markread'
- XenForo_Application::handlePhpError()
- mysqli_stmt->execute() in Zend/Db/Statement/Mysqli.php at line 208
- Zend_Db_Statement_Mysqli->_execute() in Zend/Db/Statement.php at line 297
- Zend_Db_Statement->execute() in Zend/Db/Adapter/Abstract.php at line 479
- Zend_Db_Adapter_Abstract->query() in NodesAsTabs/Install.php at line 31
- NodesAsTabs_Install::install()
- call_user_func() in XenForo/Model/AddOn.php at line 214
- XenForo_Model_AddOn->installAddOnXml() in XenForo/Model/AddOn.php at line 169
- XenForo_Model_AddOn->installAddOnXmlFromFile() in XenForo/ControllerAdmin/AddOn.php at line 178
- XenForo_ControllerAdmin_AddOn->actionInstall() in XenForo/FrontController.php at line 310
- XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
- XenForo_FrontController->run() in /var/www/xxxxxxxxx.net/htdocs/forum/admin.php at line 13
I can't reproduce this error myself and I can't figure out what might be causing it. Any ideas?
Because I can't reproduce this error I am inclined to blame his PHP configuration, but I want to check with you guys first.