我现在完全陷入了可控制的行为。在我的模型中,用户一切正常,我得到了我需要的一切:
$this->set(
'user',
$this->User->find(
'first',
array(
'contain' => array('Ad', 'Ad.Placad', 'Ad.Placad.Place'),
'conditions' => array('User.id' => $this->Auth->user('id'))
)
)
);
输出:
Array
(
[User] => Array
(
[id] => 1
[username] => admin
)
[Ad] => Array
(
[0] => Array
(
[id] => 1
[user_id] => 1
[Placad] => Array
(
[0] => Array
(
[id] => 5
[ad_id] => 1
[place_id] => 1
[Place] => Array
(
[id] => 1
[name] => kauf Bk
)
)
)
)
[1] => Array
(
[id] => 2
[user_id] => 1
[Placad] => Array
(
[0] => Array
(
[id] => 6
[unique] => 1-2
[ad_id] => 2
[place_id] => 1
[Place] => Array
(
[id] => 1
[name] => kauf Bk
)
)
)
)
但是这个:
$this->set('ad',
$this->Ad->find('first',
array(
'conditions' => array('Ad.id' => $id),
'contains' => array('Placad', 'Placad.Place'),
)
)
);
忽略Place表。
Array
(
[Ad] => Array
(
[id] => 1
[user_id] => 1
[name] => bota1
)
[Placad] => Array
(
[0] => Array
(
[id] => 5
[ad_id] => 1
[place_id] => 1
)
)
)
在Placad中应该有一个附加数组的地方信息,对吗?第一个查询正在运行,为什么第二个查询被破坏?我希望所提供的描述足够。
谢谢你们!
答案 0 :(得分:1)
错字:contain
,而不是contains