Answer the question
In order to leave comments, you need to log in
What naming convention (camelCase vs snake_case) for columns is it customary to use when using PHP and SQL JOINT?
There are recommendations that it is customary to name columns in SQL in snake_case, and variables in PHP classes in camelCase.
But when sharing models in ORM, inconsistent code occurs when the field forwarded from SQL in PHP code looks like $someModel->snake_case, that is, as a result of following both rules, what the hell is obtained.
There are options:
1) call the names of SQL columns and PHP variables in camelCase
2) and call the names of SQL columns and PHP variables in snake_case
3) SQL in snake_case, PHP in camelCase, add setters / getters to the model for converting back and forth (laravel eloquent allows you to do this out of the box, but still some kind of crutch, when writing a raw request, snake_case pops up again)
4) score on inconsistency, you give a mixture of styles!
5) other
Which option is better to use and why?
Made a vote: https://docs.google.com/forms/d/e/1FAIpQLSdK17-sDL...
Answer the question
In order to leave comments, you need to log in
3. snake_case_sql, camelCasePhp. Normal ORMs have something like namingStrategy that does all the work for you.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question