开发者

cakephp find all data format

I am using following to find data.

$records = $this->ModelName->find('all', array('fields' => array('name','email')));

It gives me data in following format.

Array
(
    [0] => Array
        (
            [ModelName] => Array
                (
                    [name] => val
                    [email] => value1
                )
        )
    [1] => Array
        (
            [ModelName] => Array
                (
                    [name] => val
                    [email] => value1
                )
        )
)

Can I get the data in following format? If yes, how? I need following format of data array.

Array
(
    [0] => Array
        (
              [name] =>开发者_开发百科; val
              [email] => value1
        )
    [1] => Array
        (
              [name] => val
              [email] => value1
        )
)


This will do

$new_array = Set::classicExtract($records, '{n}.ModelName');


foreach ($records as $i => $record) {
    $records[$i] = $record['ModelName'];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜