Yii Framework Forum

ActiveRecord property is not defined after rename - solved


(Bunny) #1

I step many times in the same river in the past. I am pretty sure, many ppl have a same problem, so I think sharing the solution is a good idea.

I got a migration file with syntax error. Not a big mistake, for example the column name with wrong case, Name and not name in the table creation command. You realize this mistake after you create your Model file and using that ActiveRecord class in many place.

So, you want to reapir this problem. The correct way is to make a new migration file with ALTER or repair in the original migration file, if that is not yet publicated. Then replace the wrong table column’s attribute to the correct case in the project. Everything looks fine, there is no wrong uppercase in the whole project. Lets reload a page: “Error! The … property is not defined” !

What the hell? You try to find the problem, but there is everything looks just fine, the Yii take from some magical place the outdated information. But from where? Then, after a short or longer time the problem is gone … just gone, start to working without reason, and you do not know: why?

So the solution that give me wasted hours and some grey hear:

DELETE the protected/runtime/cache-1.1.19.db file (the number is your Yii version)! :o :o :o

I never found this solution, so I hope it will help someone. You welcome :)