gpt4 book ai didi

php - 插入 codeigniter 时出错

转载 作者:行者123 更新时间:2023-11-29 06:13:57 28 4
gpt4 key购买 nike

我在表中插入时遇到此错误:

A Database Error Occurred
Error Number: 1452

Cannot add or update a child row: a foreign key constraint fails (`giftme`.`giftme_shop`, CONSTRAINT `shop_ibfk_2` FOREIGN KEY (`sh_cid`) REFERENCES `giftme_shop_category` (`sc_cid`) ON DELETE CASCADE)

INSERT INTO `giftme_shop` (`sh_uid`, `sh_shop_name`, `sh_cid`) VALUES ('79', 'Naveen Reddys shop', 1)

Filename: /var/www/apps/helpers/sessions_helper.php

Line Number: 55

请问有什么解决办法吗?

最佳答案

有外键引用

parent : `giftme_shop_category`.`sc_cid`
child : `giftme_shop`.sh_cid

父表中没有sc_cid=1

删除外键约束

更改表gifme_shop 删除外键shop_ibfk_2;

请阅读此处

http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html

 ALTER TABLE tbl_name DROP FOREIGN KEY fk_symbol

关于php - 插入 codeigniter 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7696952/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com