Guest User

Untitled

a guest
Mar 12th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. --This function returns true if the account with the given username (and, optionally,  password) exists, false otherwise.
  2. function getAccount(username, password)
  3.     local dbNode = getDatabaseHandler()
  4.     if not dbNode then
  5.         return false
  6.     end
  7.    
  8.     local accountQuery
  9.     if password then
  10.         accountQuery = dbQuery(dbNode, "SELECT ID FROM accounts WHERE username = ? AND password = ?", username, password)
  11.     else
  12.         accountQuery = dbQuery(dbNode, "SELECT ID FROM accounts WHERE username = ?", username)
  13.     end
  14.     local accountResult, numRows = dbPoll(accountQuery, -1)
  15.     dbFree(accountQuery)
  16.    
  17.     return (numRows > 0 and true) or false
  18. end
Add Comment
Please, Sign In to add comment