Cakephp ClassRegistry :: init at boot

Is it possible to use the model in bootstrap.php to get an array using find () from the database?

like this:

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

thanks

+6
source share
2 answers

You need to manually load the classes you use, if you really have to use the basic internal things that used to be.

to try

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

before using ClassRegistry.

+10
source

Write to bootstrap.php

 App::uses('ClassRegistry', 'Utility'); $Setting = ClassRegistry::init('ModelName'); 
+2
source

Source: https://habr.com/ru/post/913025/


All Articles