【发布时间】:2014-11-28 04:25:38
【问题描述】:
我正在为我的网站创建一个模块,这里我使用 hookActionProductUpdate 钩子在 ps_game_key 表中插入一些值。当产品更新时,插入查询会执行两次。所以插入 2 条记录而不是插入 1 条记录。这似乎hookActionProductUpdate 被调用了两次。请帮助
class customsupplier
{
public function __construct()
{
$this->name = 'customsupplier';
$this->tab = 'front_office_features';
$this->version = '1.0';
$this->author = 'Rex';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('Custom Supplier');
$this->description = $this->l('Custom Supplier Module');
}
public function install()
{
if (!parent::install() OR
!$this->alterTable('add') OR
!$this->registerHook('actionAdminControllerSetMedia') OR
!$this->registerHook('actionProductUpdate') OR
!$this->registerHook('displayAdminProductsExtra'))
return false;
return true;
}
public function hookActionProductUpdate($params)
{
Db::getInstance()->insert('game_key', array(
'id_product' => 89,
'key_type' =>'test',
'game_key' => 'reee',
'added_date_time'=> 'ssd'
),true);
}
}
【问题讨论】:
标签: php mysql mysqli smarty prestashop