做$這個 - 後>事件 - >找到()我得到以下結果:
array(
'Event' => array(
'event_id' => '72',
'user_id' => '54c7e9f9-2520-48ca-ab70-1dfccf31a6d6',
'title' => 'dfg',
'start' => '2015-02-11 20:28:00',
'public' => '0'
),
'User' => array(
'password' => '*****',
'id' => '54c7e9f9-2520-48ca-ab70-1dfccf31a6d6',
'username' => '*',
'slug' => '',
'password_token' => null,
'email' => '*',
'email_verified' => true,
'email_token' => '*',
'email_token_expires' => '2015-01-28 20:41:45',
'tos' => true,
'active' => true,
'last_login' => '2015-02-11 23:17:48',
'last_action' => null,
'is_admin' => true,
'role' => 'registered',
'created' => '2015-01-27 20:41:45',
'modified' => '2015-02-11 23:17:48'
),
'EventGuest' => array(
(int) 0 => array(
'id' => '84',
'event_id' => '72',
'guest_id' => '54db93be-0ef8-47d2-9bdb-118ccf31a6d6',
'accepted' => '1'
),
(int) 1 => array(
'id' => '85',
'event_id' => '72',
'guest_id' => '54d1185f-8968-485e-b88f-1dd8cf31a6d6',
'accepted' => '0'
)
)
)
我怎樣才能解決guest_id的用戶名,分佈在表的用戶?
基本上我想要的東西輸出如下: ...
'EventGuest' => array(
(int) 0 => array(
'id' => '84',
'event_id' => '72',
'guest_id' => '54db93be-0ef8-47d2-9bdb-118ccf31a6d6',
'username' => 'Test',
'accepted' => '1'
),
(int) 1 => array(
'id' => '85',
'event' => '72',
'guest_id' => '54d1185f-8968-485e-b88f-1dd8cf31a6d6',
'username' => 'Test2',
'accepted' => '0'
)
)
)
(請注意現場用戶名)
我怎樣才能做到這一點頭也不擡每單個用戶名一個,還是有一個不錯的CakePHP功能?
關係:
事件:
屬於關聯:
- 用戶
的hasMany:
- EventGuest
EventGuest:
屬於關聯:
- 事件
- 用戶
用戶
的hasMany:
- 事件
- EventGuest
能否請你解釋一下我,我怎麼能有效地解決這個問題呢?
隨着親切的問候,
Battlestr1k3
不幸的是,這並沒有帶來理想的結果,現在在結果中沒有EventGuest。在Event.php中,我添加了公共$ actsAs = array('Containable');,以及在User.php和EventGuest.php中。 – Battlestr1k3 2015-02-12 13:06:36
對於用戶模型我使用插件位於unter /插件/用戶,也許這可能是重要的關係 – Battlestr1k3 2015-02-12 13:38:41