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
  • 15,723
  • 6
  • 44
  • 66
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,478
  • 3
  • 46
  • 67
2

Write in bootstrap.php

App::uses('ClassRegistry', 'Utility');
$Setting = ClassRegistry::init('ModelName');
josliber
  • 41,865
  • 12
  • 88
  • 126