CakePHP 我正在使用可包含的行为,但我怀疑是否要停止来自中间模型的数据。
假设我有这个结构
Song -> Tracklist -> Album
所以当我把Containable
行为放在Song Model
它上面时,会用所需的字段取出专辑数据。但在每次调用中,它也会获取中间模型 Tracklist 的全部数据。
我的可包含行为是这样的。
$contain = array('Tracklist'=>array('Album'=>array('id','name')));
$this-Song->find('first', array('contain'=>$contain));
像这样。我的数据就像
[Tracklist] => Array
(
[0] => Array
(
[id] => 50
[album_id] => 229
[song_id] => 38
[video_link] =>
[status] => 0
[featured] => 0
[user_id] =>
[created] =>
[modified_by] =>
[modified] =>
[Album] => Array
(
[name] => Marasim
[slug] => marasim
)
)
[1] => Array
(
[id] => 2748
[album_id] => 489
[song_id] => 38
[video_link] =>
[status] => 1
[featured] => 0
[user_id] =>
[created] => 2013-10-09 17:58:53
[modified_by] =>
[modified] => 2013-10-09 17:58:53
[Album] => Array
(
[name] => Dummy Album
[slug] => dummy-album
)
)
)
[2] => Array
(
[id] => 2749
[album_id] => 489
[song_id] => 38
[video_link] =>
[status] => 1
[featured] => 0
[user_id] =>
[created] => 2013-10-09 17:59:42
[modified_by] =>
[modified] => 2013-10-09 17:59:42
[Album] => Array
(
[name] => Dummy Album
[slug] => dummy-album
)
)
)
我只想限制来自中间模型的数据。那可能吗 ?