prestashop 模块中的 SQL 语法错误

问题描述 投票:0回答:1

当我在安装方法中运行sql代码时,它显示语法错误。

我的sql代码:

CREATE TABLE PREFIX_wallet (
    `id` INT NOT NULL,
    `id_customer` INT NOT NULL,
    `cash` INT DEFAULT 0,
    `data_add` DATETIME DEFAULT CURRENT_TIMESTAMP,
    `data_upd` DATETIME DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    FOREIGN KEY (`id_customer`) REFERENCES `PREFIX_customer`(`id_customer`) 
);

CREATE TABLE PREFIX_wallet_history (
    `id` INT NOT NULL,
    `id_customer` INT NOT NULL,
    `id_wallet` INT NOT NULL,
    `last_amount` INT NOT NULL,
    `Summary` TEXT(255) NOT NULL,
    `data_add` DATETIME DEFAULT CURRENT_TIMESTAMP,
    `data_upd` DATETIME DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    FOREIGN KEY (`id_customer`) REFERENCES `PREFIX_customer`(`id_customer`),
    FOREIGN KEY (`id_wallet`) REFERENCES `PREFIX_wallet`(`id`) 
);

前缀部分替换为 DB_PREFIX 代码。

错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE ps_wallet_history (
id INT NOT NULL,
id_customer INT NOT NU' at line 11<br /><br /><pre>CREATE TABLE ps_wallet (
id INT NOT NULL,
id_customer INT NOT NULL,
cash INT DEFAULT 0,
data_add DATETIME DEFAULT CURRENT_TIMESTAMP,
data_upd DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
FOREIGN KEY (id_customer) REFERENCES ps_customer(id_customer)
);

CREATE TABLE ps_wallet_history (
id INT NOT NULL,
id_customer INT NOT NULL,
id_wallet INT NOT NULL,
last_amount INT NOT NULL,
Summary TEXT(255) NOT NULL,
data_add DATETIME DEFAULT CURRENT_TIMESTAMP,
data_upd DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
FOREIGN KEY (id_customer) REFERENCES ps_customer(id_customer),
FOREIGN KEY (id_wallet) REFERENCES ps_wallet(id)
);</pre>

我考了全部`,但是没有结果。 感谢您的帮助。

php module prestashop
1个回答
0
投票

必须先创建ps_customer表,使用这段代码看看是否能解决你的问题:

CREATE TABLE ps_customer (
id_customer INT NOT NULL,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
PRIMARY KEY (id_customer)
);

CREATE TABLE ps_wallet (
id INT NOT NULL,
id_customer INT NOT NULL,
cash INT DEFAULT 0,
data_add DATETIME DEFAULT CURRENT_TIMESTAMP,
data_upd DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
FOREIGN KEY (id_customer) REFERENCES ps_customer(id_customer)
);

CREATE TABLE ps_wallet_history (
id INT NOT NULL,
id_customer INT NOT NULL,
id_wallet INT NOT NULL,
last_amount INT NOT NULL,
Summary TEXT(255) NOT NULL,
data_add DATETIME DEFAULT CURRENT_TIMESTAMP,
data_upd DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
FOREIGN KEY (id_customer) REFERENCES ps_customer(id_customer),
FOREIGN KEY (id_wallet) REFERENCES ps_wallet(id)
);
© www.soinside.com 2019 - 2024. All rights reserved.