mysql - How to solve this error SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails -
mysql - How to solve this error SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails -
sqlstate[23000]: integrity constraint violation: 1452 cannot add together or update kid row: foreign key constraint fails (marketplace
.mg_nbmp_review
, constraint fk__nbmp_vendor
foreign key (vendor_id
) references ('marketplace/vendor')
(vendor_id
) on delete cascade on update cascade), query was: insert mg_nbmp_review
(vendor_id
, vendor_name
, customer_id
, customer_name
, customer_email
, rating
, review_comment
, reviewed_date
) values (?, ?, ?, ?, ?, ?, ?, '2015-04-08 11:51:58')
<?php $installer = $this; $installer->startsetup(); $installer->run(" drop table if exists {$this->gettable('vendorreview/review')}; create table if not exists {$this->gettable('vendorreview/review')} ( `review_id` int(11) not null auto_increment, `vendor_id` int(11) not null default '0', `vendor_name` varchar(1000) not null default '0', `customer_id` int(10) unsigned not null default '0', `customer_name` varchar(255) not null default '0', `customer_email` varchar(255) not null default '0', `rating` enum('1','2','3','4','5') not null, `review_comment` varchar(1000) null default '0', `reply` varchar(255) null default '0', `status` int(10) not null default '0', `reviewed_date` datetime not null default '0000-00-00 00:00:00', primary key (`review_id`), index `fk__nbmp_vendor` (`vendor_id`), index `fk__customer_entity` (`customer_id`), constraint `fk__nbmp_vendor` foreign key (`vendor_id`) references {$this->gettable('marketplace/vendor')} (`vendor_id`) on update cascade on delete cascade, constraint `fk__customer_entity` foreign key (`customer_id`) references {$this->gettable('customer/entity')} (`entity_id`) on update cascade on delete cascade ) comment='vendor review table' engine=innodb; "); $installer->endsetup();
where m wrong?
first should not drop table describe above reply & error shows trying insert value vendor_id not in master table marketplace/vendor's vendor_id column value. means foreign key violation. inserting wrong value not refers value in master table.
mysql sql-server
Comments
Post a Comment