Bootstrap 中的 Cakephp ClassRegistry::init

标签 cakephp cakephp-2.1 bootstrapping

我可以使用 bootstrap.php 中的模型通过 find() 从数据库中获取数组吗?

像这样:

$Setting = ClassRegistry::init('Setting');
$Settings = $Setting->find('all');

谢谢

最佳答案

如果您确实必须尽早使用核心内部内容,那么您需要手动加载使用的类。

尝试

App::uses('ClassRegistry', 'Utility');

在实际使用 ClassRegistry 之前。

关于 Bootstrap 中的 Cakephp ClassRegistry::init,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10122682/

相关文章:

cakephp - 自 "HABTM"或 "HasMany Through"概念混淆

session - 如果不在 session 中(如果他没有登录),如何在 Zend Framework 2 中配置 Module.php 以重定向用户?

css - CakePHP,不显示 CSS 文件中的背景图像

mysql - mysql错误

css - 单选按钮和标签 Cakephp 之间的空间

mysql - 在 Cakephp 2.2 上作为字符串返回的 Float、Decimal、Int mysql 字段

compiler-construction - 引导编译器:为什么?

ubuntu - 如何在 Ubuntu 14.04 上安装最新的 Boost 版本?

cakephp - 在 cakephp 下拉菜单中添加默认选项 "Please Select"

cakephp - MVC : Correct pattern to reference objects from a different model