Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Problem Model camelCase properties

Hi there I'm staring in Phalcon and I have a little problem

class Foo extends \Phalcon\Mvc\Model {
private $somevar;
private $some_var;
private $someVar;

DB table have the same property sintax Well store dommy data but when I fetch some object

echo $foo->somevar; //ok
echo $foo->some_var; //ok
echo $foo->someVar; // NULL 

Any idea how to fix?

Windows 7 x64 PHP 5.6.14 Phalcon 2.1.0b

edited Nov '15

You cant(well you shouldnt) mix camelCase and under_score and nocase. Use camelCase or under_score, with camelCase use columnMap like this:

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

You can create model like BaseModel extending phalcon Model and then your Models extending BaseModel

Its kind of stupid to have somevar, some_var,someVar names, it just looks so bad.

Thanks well I didn't mix that three styles. I have nocase and camelCase.

class User extends Model {
private $idUser;
private $name;
private $password;
private $createdAt;
//.... setters and getters...

I dont have problems with "nocase" properties but cameCamel case always return NULL

Ofc you can use without any case. Just use code which i give you above. In base you are using under_score, in code use camelCase, also you shouldnt name id of user idUser, its already User class, you dont have to repeat User.

Yes with under_score in db and cameCase in app work great! thx :D