I am new to Cake and tried to find the best solution for getting a specific field belonging to $ id:
This is my view function in Post controller
function view($id = null) { if (!$id) { $this->Session->setFlash(__('Invalid post', true)); $this->redirect(array('action' => 'index')); } $this->set('post', $this->Post->read(null, $id)); }
The message table has a foreign key user_id. I need to get this specific field belonging to this $ id post.
I read about functions like find ("Everything"), read (), or just throw an unconventional session in the form via:
$session->write('example') = $post['Post']['user_id];
What is the best way to do this, I prefer to retrieve the field in the controller. Thanks!
source share