【问题标题】:ErrorException [ Error ]: Class 'Model_Search' not foundErrorException [错误]:找不到类“Model_Search”
【发布时间】:2013-02-08 03:45:03
【问题描述】:

我从我的本地主机移动到我的网络主机以测试应用程序,一切都按预期工作,但是当我尝试使用通过 oil 生成的模型时,它会抛出该错误,说该类不存在,当它发生时。

我正在使用的代码:

use \Model\Search;

class Controller_Search extends Controller_Template
{
    public function action_search()
    {
        if ($_POST['Search']) {
            $name['communities'] = Model_Search::query()->where('zip', '=', $_POST['Search'])->get();
            $name['count'] = count($name['communities']);
            $this->template->title = 'Search » Search';
            $name['canShow'] = true;
            $this->template->content = View::forge('search/search', $name);

        } else {
            $name['count'] = 0;
            $this->template->title = 'Search » Search';
            $name['canShow'] = false;
            $this->template->content = View::forge('search/search', $name);
        }
    }

}

问题是,这是什么原因造成的?我该如何解决??

【问题讨论】:

  • 您是否在项目中定义了“Model_Search”类?它是在同一个命名空间中还是在不同的命名空间中?试试“\Model_Search”并告诉我

标签: php orm fuelphp


【解决方案1】:

在定义和自动加载器方面,\Model\Search 都不同于 \Model_Search,即使两者都指向同一个文件。

因此,请下定决心如何使用模型并保持一致。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-21
    • 2012-04-18
    • 2019-01-05
    相关资源
    最近更新 更多