Code Style - Database Fields


how should database fields be named in Yii2?

first_name or firstName?

"Property names MUST be declared in camelCase" … but also for active records (db fields)?

e.g. "person" table:

first_name = db field

last_name = db field

fullName = getter

echo $person->first_name;

echo $person->last_name;

echo $person->fullName;




First variant is a bit more safer because you’re avoiding case sensitivity issues that present in many DBs. Different naming for DB fields is telling you these are from DB.