在表中添加一些列后,ORM 无法找到这些列,除非我在 Kohana3 中运行 reload()
在我向表中添加一些列后,我的模型找不到这些新列,但可以找到现有列。
例如,假设我向 user
表添加一个 point
列,并且 name
列已存在。
$foo = ORM::factory('user',1);
$foo->name; // it's ok
$foo->point; // would throw exception:The :property property does not exist in the :class class
$foo->reload();
$foo->point; // would work
如您所见,如果我在获取新列之前添加 reload() ,它就会起作用。但我真的不认为这是正确的做法。而且我之前更改了架构,没有问题。寻找永久解决方案..
After I add some columns to the table, my model can't find those new columns but can find the existing ones.
For example, suppose I add a point
column to the user
table, and column name
is existed one.
$foo = ORM::factory('user',1);
$foo->name; // it's ok
$foo->point; // would throw exception:The :property property does not exist in the :class class
$foo->reload();
$foo->point; // would work
As you see, if I add reload() before I fetch the new column, it would work. But I really don't think this is the right way to do that. And I changed the schema before, there was no problem.Looking for a permanent solution..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我弄清楚如何解决这个问题。
只需删除
cache/.kohana/
目录下的所有文件即可,该目录是kohana保存数据库模式缓存的地方。I figure out how to solve this issue.
Just delete all the files in the directory:
cache/.kohana/
, that is the place where kohana keep the cache of the database schema.