我正在使用wordpress 4.9.6
具有mysqlnd 5.0.12-dev
作为db。我已经创建了自己的表,它使用post\\u id作为外键约束。
当我想删除后端中的帖子时,我会得到:
WordPress database error: [Cannot delete or update a parent row: a foreign key constraint fails (`my_own_database`.`wp_product`, CONSTRAINT `wp_product_ibfk_1` FOREIGN KEY (`post_id`) REFERENCES `wp_posts` (`ID`))]
DELETE FROM `wp_posts` WHERE `ID` = 300
Error in deleting.
我引用post\\u id的表如下所示:
CREATE TABLE wp_product(
id BIGINT(20) NOT NULL AUTO_INCREMENT,
post_id BIGINT(20) UNSIGNED,
product_id BIGINT(20) NOT NULL,
daily_netProfit DECIMAL(30,15) NOT NULL,
daily_grossProfit DECIMAL(30,15) NOT NULL,
daily_costs DECIMAL(30,15) NOT NULL,
created_at DATETIME NULL,
updated_at DATETIME NULL,
PRIMARY KEY (id),
FOREIGN KEY (post_id) REFERENCES wp_posts(ID),
FOREIGN KEY (product_id) REFERENCES {$wpdb->prefix}products(id)
);
在我的后端按delete按钮时,有没有建议如何删除帖子?
感谢您的回复!