在路由文件中使用模型,cakephp [英] Using Model in routes file, cakephp

查看:27
本文介绍了在路由文件中使用模型,cakephp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望从我的/app/Config/routes.php 配置文件中的数据库加载值.

I am looking to load values from my database in my /app/Config/routes.php configuration file.

在顶部我使用:App::uses('Option', 'Model');

我在我的班级中调用我的 find :$this->Option->find('all');

And I am calling my find in my class: $this->Option->find('all');

我错过了什么吗?

推荐答案

认为你必须在使用模型之前实例化它:

I think you have to instantiate the model before you use it:

App::uses('Option', 'Model');
$option = new Option();
$something = $option->find('all');

这篇关于在路由文件中使用模型,cakephp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆