lundi 6 avril 2015

why only if statement works? Any mistakes in my code(count() statement)?

i've a problem with mysql source. i have no idea how to fix it. it works at mysql but something weird. for example, if i have no rows in ID/PWD column, if statement is work and return 1. i really don't know why... but 'if statement' is working. i think it should go to 'else if statement' and return 2; or should go to 'else statement' and return 0..! plz help me





var mysqlUtil = module.exports = {
Login: function(nickname, password) {
if(connect.query('SELECT COUNT(*) FROM ' + TABLE + ' WHERE ID = ? AND PWD = ?', [nickname, password]))
{
return 1;
}
else if(connect.query('SELECT COUNT(*) FROM ' + TABLE + ' WHERE auth_ID = ? AND auth_PWD = ?', [nickname, password]))
{
return 2;
}
else
{
return 0;
}
}



Aucun commentaire:

Enregistrer un commentaire