我有这些表:
表:创作者
obs.:我也试过这样:
表:帖子
CreatorModel.php
class CreatorModel extends AppModel {
public $actsAs = array('Containable');
public $hasOne = array('Post');
}
PostModel.php
class PostModel extends AppModel {
public $actsAs = array('Containable');
public $hasOne = array('Creator');
}
索引控制器.php
$this->set('posts', $this->Post->find());
索引.ctp
var_dump($posts);
在关于关联 的 CakeBook 会议之后http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html
鉴于以下情况,我应该收到该回复:
Array
(
[Post] => Array
(
[id] => 1
[creator_id] => 1
[tags] =>
[title] => Teste
[post] => Maromba
[created] => 2013-04-29 19:14:32
[modified] => 2013-04-29 19:14:32
)
[Creator] => Array
(
[creator_id] => 1
[creator] => Alexandre Moraes
)
)
但我收到这个:
Array
(
[Post] => Array
(
[id] => 1
[creator_id] => 1
[tags] =>
[title] => Teste
[post] => Maromba
[created] => 2013-04-29 19:14:32
[modified] => 2013-04-29 19:14:32
)
)
那么,有什么想法我做错了吗?