I wish to update my sql value for my custom module, but since this value is in a separated sql table, I stuck ...
The first value, MY_TOPBAR, is updated correctly since she is updated in the ps_configuration table, but my second value, MY_HTML_DATA, isn't updated correctly in my table ps_mymodule.
Here is my php code :
public function getContent()
{
// If we try to update the settings
$output = '';
if (Tools::isSubmit('submit'.$this->name))
{
Configuration::updateValue('MY_TOPBAR', Tools::getValue('MY_TOPBAR', ''));
Configuration::updateValue('MY_HTML_DATA', Tools::getValue('MY_HTML_DATA', ''));
Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules').'&configure='.$this->name.'&tab_module='.$this->tab.'&conf=4&module_name='.$this->name);
}
return $output.$this->displayForm();
}
How I can update correctly my MY_HTML_DATA value ?
Thanks
#I finally used the method provided by @yenshirak and here it's the final code who permit to update my custom table, without loose of any html data =>
public function getContent()
{
// If we try to update the settings
$output = '';
if (Tools::isSubmit('submit'.$this->name))
{
Configuration::updateValue('MY_TOPBAR', Tools::getValue('MY_TOPBAR', ''));
$MY_HTML_DATA = pSQL( Tools::getValue('MY_HTML_DATA', ''), true );
$sql='UPDATE `'._DB_PREFIX_.'mymodule` SET `data` = "'.$MY_HTML_DATA.'" WHERE `option` ='MY_HTML_DATA';';
if(Db::getInstance()->Execute($sql))
Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules').'&configure='.$this->name.'&tab_module='.$this->tab.'&conf=4&module_name='.$this->name);
}
return $output.$this->displayForm();
}
Aucun commentaire:
Enregistrer un commentaire