Cakestp ClassRegistry :: init in bootstrap

ali*_*786 6 bootstrapping cakephp cakephp-2.1

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

像这样 :

$Setting = ClassRegistry::init('Setting');
$Settings = $Setting->find('all');
Run Code Online (Sandbox Code Playgroud)

谢谢

mar*_*ark 10

如果你真的必须尽早使用核心内部的东西,你需要手动加载使用过的类.

尝试

App::uses('ClassRegistry', 'Utility');
Run Code Online (Sandbox Code Playgroud)

在你真正使用ClassRegistry之前.