I'm no Cake god either, but my first idea was to do it on
AppController...
Put this on app_controller.php, on the /app directory:
<?php
class AppController extends Controller {
function beforeFilter() {
$configModel = loadModel("configModelName");
$parameters = $configModel->findAll();
foreach ($parameters as $parameter)
define($parameter['Parameter']['name'],
$parameter['Parameter']
['value']);
}
}
?>
You just have to be careful that the constant value
( $parameter['Parameter']['value'] ) always evaluate to a scalar
value (i.e., it's not an array or object).
Greetings,
Luiz F.
On Dec 16, 2:21 pm, glastoveteran <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Sorry for the stupid question, but how can I access a model's function
> (.e.g. findAll) from bootstrap.php?
>
> i.e. I have configuration parameters stored in a db table and I want
> to set them as constants at startup time. My model name is Parameter
> (parameter.php).
>
> // something like
> $parameters = $this->model->Parameter->findAll();
> foreach ($parameters as $parameter) {
> define($parameter['Parameter']['name'], $parameter['Parameter']
> ['value']);
>
> }
>
> Thanks, Alex
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---