Modified something in your database? Be sure to clear the model cache!!!

This point deserves its own post.

Those who hang out on the friendly and helpful IRC channel, probably see this come up every week at least 3 times :)

Remembering to clear the cache every time the Data Base is modified, will hopefully save some people a few hours of head-scratching, because it solves a number of the problems…

What problems? … Well, let’s see:

– Bob modified some model, but the changes aren’t talking place (Did Bob modify the DB as well? Yep. Clear the cache!)
– Jerry renamed the file from user.php to user_table.php and renamed the class to “UserTable” (Modify DB? Clear the cache!)
– Somebody changed the primary key name, but the data in the view isn’t showing up (Yes, clear the cache!)

… this list can go on for a while, but the solution remains the same. Just remember to do it.

And thanks to room34 for pointing this problem out… and, actually, he quite amusingly describes this and another important issue of CakePHP on his blog. I really suggest everyone gives it a read as is it will solve some mysteries of CakePHP development.

Related Posts