We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Auto Column Map?

Is there a way to auto-column-map my properties in name convention like firstName, lastName to fields in database like first_name last_name etc or I have to do this by hand in each model ?

have you ever try the developers tool in phalcon? when you creating model it has capability to auto map the fields in database

Yea i know but its creating models with _ and i want camelcase

you can make it with camelcase but auto column map will not support this maybe you can manually change this like this

<?php

class Robots extends \Phalcon\Mvc\Model { public $code; public $theYear; public $theName; public $theType;

public function columnMap()
{
    //Keys are the real names in the table and
    //the values their names in the application
    return array(
        'id' => 'code',
        'the_name' => 'theName',
        'the_type' => 'theType',
        'the_year' => 'theYear'
    );
}

}

Yea i know i can do it this but i want some automatic way, there should be an option to make it like this in automatic way, like models with camelcase and in database using underscore