LoginSignup
5
6

More than 5 years have passed since last update.

CakePHPのfind('list')でfieldsを3つ指定すると。

Posted at

こんなデータがあったとして

【users】

id name role
1 alegriaghost Admin
2 あれぐりあごーすと User
3 アレグリアゴースト User

こう書くと

FindList.php
$fields = array(
    'User.id',
    'User.name',
    'User.role',
);

$params = array(
    'fields' => $fields,
);

$findList = $this->User->find('list', $params);

こう返ってくるらしい。

結果
$findList = Array(
    ['Admin'] => Array(
        [1] => 'alegriaghost',
    )

    ['User'] => Array(
        [2] => 'あれぐりあごーすと',
        [3] => 'アレグリアゴースト',
    )
)
5
6
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
6