开发者

error while inserting in codeigniter

开发者 https://www.devze.com 2023-04-11 20:38 出处:网络
I am getting this error while inserting in my table: A Database Error Occurred Error Number: 1452 Cannot add or update a child row: a foreign key constraint fails (`giftme`.`giftme_shop`, CONSTRAIN

I am getting this error while inserting in my table:

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`) REF开发者_如何学GoERENCES `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

Any solution please?


there is foreign key reference

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

there is no value of sc_cid=1 in parent table

Remove Foreign Key constraint

ALTER TABLE giftme_shop DROP FOREIGN KEY shop_ibfk_2;

read here

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

 ALTER TABLE tbl_name DROP FOREIGN KEY fk_symbol
0

精彩评论

暂无评论...
验证码 换一张
取 消