6

can I use a model in bootstrap.php to get an array with find() from database ?

like this :

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

thanks

Siguza
  • 21,155
  • 6
  • 52
  • 89
ali786
  • 142
  • 3
  • 10

2 Answers2

10

You need to manually load the used classes then, if you really must use core internal stuff that early.

try

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

before you actually use ClassRegistry.

mark
  • 21,691
  • 3
  • 49
  • 71
2

Write in bootstrap.php

App::uses('ClassRegistry', 'Utility');
$Setting = ClassRegistry::init('ModelName');
josliber
  • 43,891
  • 12
  • 98
  • 133