安装模块时Prestashop创建数据库表

时间:2018-11-04 19:39:01

标签: php

我用prestashop验证器创建了一个新模块。我希望在安装模块时创建一个与模块相关联的表。 为此,我在module.php的install方法级别包含了文件install.php,如下所示,但它没有在数据库中创建。

public function install()
{
    require_once 'sql/install.php';
    Configuration::updateValue('MYMDOULE_TWO_LIVE_MODE', false);

    return parent::install() &&
        $this->registerHook('header') &&
        $this->registerHook('backOfficeHeader') &&
        $this->registerHook('displayFooter') &&

        $this->registerHook('displayHeader');

}

$sql = array();

$sql[] = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'mymdoule_two` (
    `id_mymdoule_two` int(11) NOT NULL AUTO_INCREMENT,
    PRIMARY KEY  (`id_mymdoule_two`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8;';
foreach ($sql as $query) {
    if (Db::getInstance()->execute($query) == false) {
        return false;
    }
}

在安装时如何获取mdoule的特定表?

0 个答案:

没有答案