I have a table called Settings
with fields key
, value
and in a view I have to show 5 items from this table using CakePHP, in Controller
's action I have put this:
$this->set('config', array(
'key1' => $this->Setting->getValue('key1'),
'key2' => $this->Setting->getValue('key2'),
'key3' => $this->Setting->getValue('key3'),
'key4' => $this->Setting->getValue('key4'),
'key5' => $this->Setting->getValue('key5')
));
and in Setting->getValue();
I have this:
function getValue($strKey){
$value = $this->find('first', array(
'conditions' => array(
'key' => $strKey
),
'fields' => array(
'Setting.value'
)
));
return $value['Setting']['value'];
}
there's a more "CakePHP way" to do that?
Thanks.