Let sql do the searching

This commit is contained in:
Eliot Whalan 2016-06-26 21:14:12 +10:00
parent 672ce0d77a
commit a1d4ee2287
1 changed files with 6 additions and 6 deletions

View File

@ -89,12 +89,12 @@ func save(raw string, lang string, title string, expiry string) []string {
check(err)
sha := hash(raw)
query, err := db.Query("select id, title, hash, data, delkey from pastebin")
query, err := db.Query("select id, title, hash, data, delkey from pastebin where hash=?", sha)
if err != sql.ErrNoRows {
for query.Next() {
var id, title, hash, paste, delkey string
err := query.Scan(&id, &title, &hash, &paste, &delkey)
check(err)
if hash == sha {
url := ADDRESS + "/p/" + id
return []string{id, title, hash, url, paste, delkey}
}