내 사용자 클래스의 일부인이 코드가 있습니다. 나는이 함수를 호출 할 때 :'이'내 클래스의 기능이 작동하지 않습니다
user = new User();
user.regUser("john", "[email protected]", "john123", function() { });
을 나는 오류를 얻을
Uncaught TypeError: Object #<Database> has no method 'writeDb'
사용자 클래스의 기능 :
User.prototype.regUser = function(name, email, password, cb) {
this.db.exec("SELECT * from users WHERE user_email='"+email+"';", function(results) {
var len = results.rows.length;
if (typeof(cb) == 'function') {
if (len < 1) {
this.name = name;
this.email = email;
this.password = password;
this.writeDb();
cb(true); // username doesn't exists
} else {
cb(false); // username already exists
}
}
});
}
이 문제가 '이'변수가 호출되는 것을 어쩌면인가 내 함수의 중첩 된 함수에서? 다른 함수에서는 중첩되지 않을 때 작동합니다. 이 문제를 어떻게 해결할 수 있습니까?
- 작은 편집 : this.writeDb()이어야한다 내가 작성한 this.db.writeDb() 여전히 오류가 비록 얻을.
offtopic :이 검색어를 실행하지 않으려면 다음과 같이하십시오. ?????? – Christoph
아니요, 저는 왜 webSQL을 사용하고 있습니까? ' ";" –
내가 + 이메일 + 크리스토프는 "USER_EMAIL =이 WHERE 사용자로부터 SELECT *' ''는 사실을 언급 생각'[SQL 인젝션에 취약]입니다 (http://xkcd.com/327/). –