С:
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));
}
Я могу найти связанных пользователей, но у них есть профиль.
Когда я перечисляю связанных пользователей, я хочу иметь Email профиля вместо profile_id
Post $hasAndBelongsToMany Users $belongsTo Profile.
Таблица:
Пользователи
Posts_Users
Сообщения
Профили.
ОТВЕТ:
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid Post', true));
$this->redirect(array('action' => 'index'));
}
$this->Post->recursive =2;
$this->set('post', $this->Post->read(null, $id));
}