【发布时间】:2015-04-26 08:21:38
【问题描述】:
我有一个 AngularJs 应用程序,它使用 php PDO API 连接到数据库。
这是示意图数据流:
DB:
CREATE TABLE person (
...
first_name,
...
);
php API:
$stmt = $this->db->prepare("SELECT * FROM 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; // this throws a jslint warning
});
问题是SQL推荐的命名标准是underscore_case,而Angular的是camelCase...
我不想禁用jslint,这在其他方面非常有用...
我知道我可以避免警告
{
"camelcase": false
}
在 .jshintrc 中,但我不希望全局禁用驼峰式检查...
目前我通过这种方式避免使用“jslint cmets”的 jslint 警告:
/* jshint camelcase: false */
var name = person.first_name;
/* jshint camelcase: true */
但是我的代码将包含比代码更多的 jslint cmets...非常不可读...
你(或者你会)如何解决这个问题?
【问题讨论】:
标签: php angularjs pdo camelcasing