我正在创建一个用户身份验证应用,并且正在尝试使用用户名和密码来获取特定的匹配用户。
我正在尝试这样做。
var Username = this.state.Username;
var Password = this.state.Password;
db.transaction(tx =>{
db.transaction(tx => {
console.log("Hellow");
tx.executeSql('SELECT * FROM users WHERE username ? AND password ? ', [Username,Password], (tx, results) => {
console.log(results);
});
});
});
但是此代码不返回任何内容
答案 0 :(得分:1)
我用条件号解决了我的问题,我从条件中错过了标志号
示例
var Username = this.state.Username;
var Password = this.state.Password;
db.transaction(tx =>{
db.transaction(tx => {
tx.executeSql('SELECT U.userid FROM users AS U WHERE U.username= ? AND U.password = ?; ', [Username,Password], (tx, results) => {
console.log(results);
});
});
});