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'];
}
精彩评论