We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Columns to camelCase


I'm using lower_case for table column naming, but i want to use camelCase inside my PHP scripts.

I wrote this in an own Model which extends \Phalcon\Mvc\Model:

public function columnMap()
    $columns = $this->getModelsMetaData()->getAttributes($this);
    $map = [];
    foreach ($columns as $column) $map[$column] = lcfirst(\Phalcon\Text::camelize($column));
    return $map;

It works, but does Phalcon cache column mapping? Or is there a better way to do this?

edited Aug '15

Phalcon devtools will generate a hard coded array column map too.