3.7.3.1.3 find('all')
find('all', $params)
find('all')は(複数になりうる)結果の配列を返します。このメカニズムは実に全ての find() の別種類に使われ、またpaginateにも使われます。以下はいくつかの単純な(コントローラのコードの)サンプルです。
function some_function() {
...
$allArticles = $this->Article->find('all');
$pending = $this->Article->find('all', array('conditions' => array('Article.status' => 'pending')));
$allAuthors = $this->Article->User->find('all');
$allPublishedAuthors = $this->Article->User->find('all', array('conditions' => array('Article.status !=' => 'pending')));
...
}
function some_function() {...$allArticles = $this->Article->find('all');$pending = $this->Article->find('all', array('conditions' => array('Article.status' => 'pending')));$allAuthors = $this->Article->User->find('all');$allPublishedAuthors = $this->Article->User->find('all', array('conditions' => array('Article.status !=' => 'pending')));...}
上記のサンプルでは、 $allAuthors は users テーブルの全てのユーザに等しくなります。find に何も(訳注:パラメータが)与えられないと、find には条件が何も適用されません。
find('all')の呼び出しの結果は以下のようなフォーマットになることでしょう。
Array
(
[0] => Array
(
[ModelName] => Array
(
[id] => 83
[field1] => value1
[field2] => value2
[field3] => value3
)
[AssociatedModelName] => Array
(
[id] => 1
[field1] => value1
[field2] => value2
[field3] => value3
)
)
)
find('all')のためだけに使うパラメータはありません。


























