1

I have a field in my database "user": "first_name"

When I create my Model User.php, I tried the following getter:

private $firstName;

public function getFirstName() {
   return $this->firstName;
}

This is NULL, while this one is filled with the correct values.

private $first_name;

public function getFirstName() {
   return $this->first_name;
}

Is it correct to use underscored variables here, and not camelCased ones?

Is there a possibility to use camelCased vars?

Regards

Christian
  • 152
  • 1
  • 11

1 Answers1

2

It's a matter of what you want, not what you're afraid is proper or not. I personally like "underscore" table columns and camelCased PHP scripts.

Check this one for how to declare Model::columnMap() in your model to have both functioning: underscored table columns, but camel-cased php vars.

yergo
  • 4,761
  • 2
  • 19
  • 41