Advertisement:

database code uninstall advice

Aloittaja The Wizard, helmikuu 24, 2014, 08:05:40 AP

« edellinen - seuraava »

The Wizard

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

margarett

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.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

LainaaOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

emanuele

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.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Advertisement: