Is there a good way to specify column aliases when performing find() operations on a model?
$this->User->find('first', array(
'fields' => array(
'CONCAT(firstname, ' ', surname) AS fullname',
'email',
'tel'
)
);
At the moment, if I do it like this it returns the data like this:
Array
(
[0] => Array
(
[fullname] => John Smith
)
[User] => Array
(
[email] => [email protected]
[tel] => 0123456789
)
)
Is there a way to have it return the column aliases like normal columns?
Array
(
[User] => Array
(
[fullname] => John Smith
[email] => [email protected]
[tel] => 0123456789
)
)
For this you're supposed to use Virtual Fields.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With