CakePHP我正在使用可容忍的行爲,但我懷疑停止從中間模型的數據。CakePHP可容忍的行爲限制中級模型
假設我有這樣的結構
Song -> Tracklist -> Album
所以,當我穿上Song Model
Containable
行爲,將其與所需的字段提取出專輯數據。但在每次調用中,它也會獲取中間模型曲目列表的全部數據。
我的包含行爲是這樣的。
$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
)
)
)
我只是想限制中間模型的數據。那可能嗎 ?
我有同樣的問題...希望有人有魔法停止獲取中間模型。 :( –
你不想檢索相冊數據,對吧? –
@Moyed:我不想檢索中間模型意味着我的數據應該是'Tracklist-> 0-> Album-> AlbumData'的方式。 。我該怎麼做才能從曲目列表中提取特定的數據,或者從曲目列表中獲取特定數據(像'Tracklist-> 0('id','album_id') - > Album-> AlbumData') – Sankalp