Hello:
The following code below I add to the database during install on my mod and I was wondering whats the best way to remove it when I uninstall?
$smcFunc['db_insert']('insert', '{db_prefix}shop_categories',
array('name' => 'string', 'id' => 'int', 'count' => 'int'),
array('name' => 'Companions', 'id' => '502', 'count' => '12'),
array('name' => 'id', 'type' => 'primary', 'columns' => array('id') ));
I was thinking of writing a uninstall page and using the DELETE function like this -
$smcFunc['db_insert']('delete', '{db_prefix}shop_categories',
array('name' => 'string', 'id' => 'int', 'count' => 'int'),
array('name' => 'Companions', 'id' => '502', 'count' => '12'),
array('name' => 'id', 'type' => 'primary', 'columns' => array('id') ));
Thanks
Wiz
At uninstall the table should be dropped, so there's no need to remove content inside it ;)
And the table drop is automatically managed by SMF.
And if you want to delete something you have to use a "DELETE" query, that is not implemented as a function within $smcFunc, so you'd have to write something like:
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}shop_categories
WHERE id = {int:value}',
array(
'value' => 502
)
);
Though... I think also your insert query is wrong, I wonder how it can work.