如何修复错误Kohana_Exception [0]:Model_Emails类中不存在type属性

问题描述 投票:0回答:1

我在db中更改列名(在type_id中输入),现在我无法完成请求。在代码中我没有指定任何列,为什么kohana搜索此属性“类型”。

public static function getEmails()
{
    return ( new self)
        ->find_all()
        ->as_array();
}
php sql kohana
1个回答
0
投票

没有完整的模型代码我只能告诉你,这个error is raised(结束函数),因为ORM,在自身或相关表中找不到这个值。在您的模型中查找类似代码:

class Model_Many extends ORM {
    protected $_belongs_to = array(
        'title'=> array('model' => 'Title', 'foreign_key' => 'title_id'),
    )

    protected $_table_columns = Array(
        'many_id' => FALSE,
        'title_id' => FALSE,
    );
}

$_table_columns包含您的表结构。如果没有,请删除服务器上的缓存(APPATH/cache)。

对于关系,我强烈建议阅读this

顺便说一句:不建议使用ORM获取数组。它很慢并消耗很多内存。更好地使用query builder

© www.soinside.com 2019 - 2024. All rights reserved.