Pass parameter query on controller

I’m new to cakephp
I’m having a very basic question.
I want to pass a parameter that is the result of a query model inside the controller to use it in view

For example in CODE IGNITER:


		$data= array(
		$this->load->view('admin', $data);

Inside my controller I want to use the result of $ user_Id to make a condition

I did something like

$user_id = $this->Users->find()->where([‘’ => ‘Francisco’]);
$this->set(‘users’, $users);

but I can not use the result inside my controller

How can I use $user_id[‘Users’][‘id’]); OR $user_id->name in controller?

You almost have it :slight_smile:

$user = $this->Users->find()->where([‘’ => ‘Francisco’])->first();
$this->set(‘users’, $users);

Then you can access $user->name in the view


but how can I use result $user->name in Controller?

Actually, I need use the result for load may templates according to the query result for exeample:

I do not know if it’s the best way but I thought of something like

In my table Users
id, name, template

In my controller:

$user_template = $this->Users->find()->where([‘’ => $session->read(‘’);]);




I don’t know…

The same

$user = $this->Users->find()->where([‘’ => $this->Auth->user('id)])->first();


I would recommend that you work through the tutorials

Thanks a lot Dakota!!