php - PDO + Angular: how to reconcile DB underscore_case with Angular's camelCase? -


i have angularjs app connects database using php pdo apis.

this schematic data flow:

db:   create table person (     ...     first_name,     ...   );  php api:   $stmt = $this->db->prepare("select * person");   $stmt->execute();   $result = $stmt->fetchall(pdo::fetch_assoc);   var_dump($result);   ...   'first_name' => 'alice',   ...  angular service:   getperson: function (id) {     return $http({       method: 'get',       url: apiuri + 'get' + '/' + id,     }).then(handlesuccess, handleerror);   },  angular controller:   person.getperson(id).then(function(person) {     var name = person.first_name; // throws jslint warning   }); 

the problem sql recommended naming standard underscore_case, while angular's camelcase...

i not disable jslint, useful, in other respects...

i know avoid warnings with

{   "camelcase": false } 

in .jshintrc, i'd prefer not disable camelcase check globally...

currently avoid jslint warnings "jslint comments", way:

/* jshint camelcase: false */ var name = person.first_name; /* jshint camelcase: true */ 

but code going contain more jslint comments code... quite unreadable...

how (or you) solve issue?

as underscore_case not mandatory sql , camelcase mandatory angular sesible use names suitable both environments. in case camelcase acceptable both.

in 40+ years programming never thought underscore_case useful. have preferred camelcase. rename first_name firstname not looks better solve problem.

edit

column names in standard sql can consist of letters, underscores, , digits starting letter. sql allows use spaces, reserved words, , special characters in name if enclose them in double quotation marks.

identifiers not have meaningful have unique. in choosing naming convention environment in operate has taken consideration

windows

sql case insesitive ie, name == name == name == name

unix

sql case sesitive ie, name != name != name != name

michael lato recomends pascalcase ms server, oracle uses upper underscores. mysql recomends lower underscores not mandatory see

note

on windows, innodb stores database , table names internally in lowercase


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -