gpt4 book ai didi

Kohana 3 自动加载模型

转载 作者:行者123 更新时间:2023-12-04 23:32:39 25 4
gpt4 key购买 nike

我正在尝试使用模型,但出现 fatal error ,因此我认为它没有正确自动加载。

ErrorException [ Fatal Error ]: Class 'Properties_Model' not found



违规的 Controller 行:
$properties = new Properties_Model;

该模型:
class Properties_Model extends Model
{
public function __construct()
{
parent::__construct();
}

}

我还把这门课放在三个不同的地方,希望一个能奏效,但都失败了。
他们是:
应用程序/类/模型
应用程序/模型
应用程序/模型

我错过了什么?

最佳答案

啊,这个问题直接通过电子邮件发送给我(通过我网站的联系表)!

这是我的回应(为了可能遇到此问题的其他人的利益)。

The correct location of a model named properties is

application/classes/model/properties.php

and the class definition would be as follows

class Model_Properties extends Model { }

Think of the underscore above as the directory separator. That is, if you replaced the underscore with a / you would have: 'model/properties', which will be your file under application/classes.

To load the model from a controller, you can use PHP's standard new operator or do what I prefer, which is

$propertiesModel = Model::factory('Properties');

I'm not 100% why I prefer this way... but it works for me :)

关于Kohana 3 自动加载模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2888900/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com