Created
November 16, 2013 03:21
-
-
Save dariusc93/7495497 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var connection = mysql.createConnection(dbconfig); | |
function doExist(data, callback){ | |
connection.connect(); | |
connection.query('select * from testaccount where username=?',[data.username], function(err,rows){ | |
//if(err) throw err; | |
console.log(rows); | |
if(rows[0].username){ | |
callback(true); | |
}else{ | |
callback(false); | |
} | |
}); | |
connection.end(); | |
} | |
function register(data, callback){ | |
connection.connect(); | |
connection.query('insert into testaccount set ?', data, function(err, res){ | |
console.log(err);console.log(res); | |
}); | |
connection.end(); | |
} | |
doExist({username:'username'},function(err){ | |
if(!err){ | |
register({ | |
username:'username' | |
},function(err){ | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment