这是我得到的错误。让我知道它的根本原因是什么。
sqlstate[42000]:语法错误或访问冲突:1701无法截断外键约束中引用的表( Proficiency
. t_catalog_item_recommendations
,约束 fk_t_catalog_item_recommendations_catalog_item_id
外键( catalog_item_id
)参考文献 Proficiency
. t_catalog_items
( id
))
每当我执行测试脚本时,它都会给出以下消息:
警告:为第244行调用堆栈上的/var/www/html/lib/cake/testsuite/fixture/caketestfixture.php中的“catalog\u items”创建fixture失败“sqlstate[42s01]:基表或视图已存在:1050表“t\u catalog\u items”已存在:0.0018 262208 1{main}()/var/www/html/app/webroot/test。php:0 0.1119 1133560 2. caketestsuitedispatcher::run()/var/www/html/app/webroot/test。php:97 0.1120 1133968 3. caketestsuitedispatcher->dispatch()/var/www/html/lib/cake/testsuite/caketestsuitedispatcher。php:113 0.1205 1278304 4. caketestsuitedispatcher->\u runtestcase()/var/www/html/lib/cake/testsuite/caketestsuitedispatcher。php:96 0.1314 1320376 5. caketestsuitecommand->run()/var/www/html/lib/cake/testsuite/caketestsuitedispatcher。php:253 0.1930 2144664 6. caketestrunner->dorun()/var/www/html/lib/cake/testsuite/caketestsuitecommand。php:96 0.2285 2481368 7. phpunit\u textui\u testrunner->dorun()/var/www/html/lib/cake/testsuite/caketestrunner。php:60 0.2334 2521736 8. phpunit\u framework\u testsuite->run()/var/www/html/vendor/phpunit/phpunit/phpunit/textui/testrunner。php:350 0.2538 2770160 9. phpunit\u framework\u testsuite->runtest()/var/www/html/vendor/phpunit/phpunit/phpunit/framework/testsuite。php:749 0.2538 2770288 10. caketestcase->run()/var/www/html/vendor/phpunit/phpunit/phpunit/framework/testsuite。php:779 0.2538 2770512 11. cakefixturemanager->load()/var/www/html/lib/cake/testsuite/caketestcase。php:80 0.2541 2772984 12. cakefixturemanager->\u setuptable()/var/www/html/lib/cake/testsuite/fixture/cakefixturemanager。php:234 0.2572 2784752 13. caketestfixture->create()/var/www/html/lib/cake/testsuite/fixture/cakefixturemanager。php:206 0.4597 2824904 14. trigger\u error()/var/www/html/lib/cake/testsuite/fixture/caketestfixture。php:244
1条答案
按热度按时间nc1teljy1#
文件上说:
不能对具有来自其他表的外键引用的表使用truncate,除非所有此类表也在同一命令中被截断。
所以这就是你要做的。