首页 > 解决方案 > Cakephp 4 Two new columns are not filled even after rebuilding the model from scratch multiple times

问题描述

Having been very happy with a project I was working on, I am now down in the dumps. Everything was working fine and one last addition completely broke the entire system. I have tried to find the issue, going over the code multiple times, rebuilding everything from scratch just to get out whatever mistake I may have put in the code. All of this to no avail. It would be great if someone could show me the error in my thinking.

See https://github.com/plafeber/cake_suggestions for the full model. I am not an advanced user of Github so I may not have set it up correctly. The idea was to give you the "src" and "templates" directories of my Cake 4 environment together with the database tables that it is all based on.

See the image below; the system was supposed to create new instances of'suggestioncategory'. It worked until I introduced the maxvotes and owner_id columns. Whatever I do, these columns are not filled. Cake is a beautiful system; by generating the code based on the database you can be sure that useful working scaffolding is generated and you can test the results immediately. However, after having migrated my code from my local computer (on which it works!) to my online environment, I get "The suggestioncategory has been saved." but these 2 columns are not filled. Additionally, I can't get them to show on the screen either. Only test11 and test12 are shown. Some table content became inconsistent through testing, so I truncated them all and started over. Still, the result was the same. You can see the system by going to https://multi-grade.nl/content/, logging in with foo-bar@example.com and password 123456 and then navigating to "Suggestions". Creating a new Suggestioncategory will succeed but it will not show up. It will be entered in the database the same way you see the tests in the screenshot. After having on this for days, I am hoping somebody can help me see what I am doing wrong.

Screenshot of database result

标签: sqldatabasecakephp

解决方案


根据@ndm 的评论,我清除了缓存文件夹 tmp/cache/models。事实上,问题立即得到解决。非常感谢。


推荐阅读