문제

I got a row from database table now I wish to echo only one value from this row in CakePHP. So how to do it?

$help = $this->help->findByControllerAndAction($controller ,$action)

it has four values: id, controller, action and help_text. I want to echo only controller. Any help?

도움이 되었습니까?

해결책

I suggest reading some of the documentation, more specifically this section.

To answer your question...

I assume your Help model has a unique key controller+action.

In your controller's method you will need:

$help = $this->Help->findByControllerAndAction($controller ,$action);
if ($help) {
    $this->set('help', $help);
}

In your view:

echo $help['Help']['controller'];

will show the content of the Help.controller field.

Use:

debug($help);

If $help is not defined in your view, chances are your find is not returning the results you expect.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top