在CakePHP如果我運行下面的find命令如何根據CakePHP中的子結果限制查詢結果?
$this->Instructor->find('all');
返回以下:
Array
(
[0] => Array
(
[Instructor] => Array
(
[id] => 1
[user_id] => 3
[bio] => A billionaire playboy, industrialist and ingenious engineer, Tony Stark suffers a severe chest injury during a kidnapping in which his captors attempt to force him to build a weapon of mass destruction. He instead creates a powered suit of armor to save his life and escape captivity. He later uses the suit to protect the world as Iron Man.
)
[User] => Array
(
[id] => 3
[first_name] => Tony
[last_name] => Stark
[asurite_user] => tstark
[asurite_id] =>
[password] =>
[email] => [email protected]
[created] => 2012-10-30 09:57:36
[modified] => 2012-10-30 09:57:36
)
[Course] => Array
(
[0] => Array
(
[id] => 1
[slug] => beatles
[sln] => AAA001
[course_number] =>
[title] => The Beatles
[description] => This is a class about the Beatles. If this were a real description, more information would be listed here.
[state] =>
)
[1] => Array
(
[id] => 2
[slug] => elvis
[sln] => AAA002
[course_number] =>
[title] => Elvis: The King of Rock
[description] => All about the king of rock and roll, Elvis Presley.
[state] =>
)
)
)
[1] => Array
(
...
有「導師」和「場」之間的許多一對多的關係。如何根據每個「講師」所屬的「課程」過濾結果?我嘗試沒有成功如下:
$instructors = $this->Instructor->find('all', array(
'conditions' => array('Course.id' = 2)
));
爲查找選項添加「連接」正是我需要做的。它實際上與他們在底部給出的例子非常相似。 – PHLAK