LoginSignup
5
3

More than 5 years have passed since last update.

CakePHPのfind()で取得結果からモデル名を取り除く方法

Posted at

・コントローラの中でやる場合

$things = $this->Thing->find('all');
$things = Set::extract('/Thing/.', $things);

・モデルの中でカスタムfind()を定義する場合

public $findMethods = array('getList' => true); //カスタムfindを定義
protected function _findGetList($state, $query, $results = array())
{
    if ($state == 'after') {
        $results = Set::extract('/Thing/.', $results);
        return $results;
    }
    return $results;
}

参考

Redundant ModelName in CakePHP find Results
http://stackoverflow.com/questions/11876745/redundant-modelname-in-cakephp-find-results

5
3
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
5
3