Livestreetcms - SQL Error: Cannot add or update a child row: a foreign key constraint fails

Материал из Wiki - Iphoster - the best ever hosting and support. 2005 - 2024
Перейти к:навигация, поиск
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Livestreetcms - SQL Error: Cannot add or update a child row: a foreign key constraint fails

Ошибка вида:

SQL Error: Cannot add or update a child row: a foreign key constraint fails (`ether2_cm`.`prefix_forum_topic_view`, CONSTRAINT `prefix_forum_topic_view_fk` FOREIGN KEY (`topic_id`) REFERENCES `prefix_topic` (`topic_id`) ON DELETE CASCADE ON UPDATE CASCADE) at /home/ether2/public_html/cm.xyz/engine/classes/MapperORM.class.php line 35
Array ( [code] => 1452 [message] => Cannot add or update a child row: a foreign key constraint fails (`ether2_cm`.`prefix_forum_topic_view`, CONSTRAINT `prefix_forum_topic_view_fk` FOREIGN KEY (`topic_id`) REFERENCES `prefix_topic` (`topic_id`) ON DELETE CASCADE ON UPDATE CASCADE) [query] => INSERT INTO prefix_forum_topic_view SET `topic_id`='3', `topic_views`='16' [context] => /home/ether2/public_html/cm.xyz/engine/classes/MapperORM.class.php line 35 ) 


Решение - фиксим через sql запросы:

CPanel --> phpmyadmin --> Нажимаете слева на базу --> Нажимаете на вкладку "SQL" и вводите команды по одной.

ALTER TABLE `prefix_forum_topic_view`
DROP FOREIGN KEY `prefix_forum_topic_view_fk`;    
ALTER TABLE `prefix_forum_topic_view` ADD CONSTRAINT `prefix_forum_topic_view_fk` FOREIGN KEY (`topic_id`) REFERENCES `prefix_forum_topic` (`topic_id`) ON DELETE CASCADE ON UPDATE CASCADE;