LoginSignup
2
2

More than 5 years have passed since last update.

CakePHPのfind()で関連モデルのデータを取得しない方法(joinさせない方法)

Posted at

recursiveプロパティを-1に設定する。(Cakeは当該モデルのデータだけを取得します。joinしません。)

$this->Post->recursive = -1;
$posts = $this->Post->find('all');

または、

$posts = $this->Post->find('all', array(
    'recursive' => -1,
    'conditions' => ...
);

参考

モデルの属性
http://book.cakephp.org/2.0/ja/models/model-attributes.html#recursive

Retrieving models without getting associated models - CakePHP
http://stackoverflow.com/questions/5575884/retrieving-models-without-getting-associated-models-cakephp

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2