Let sql do the searching
This commit is contained in:
parent
672ce0d77a
commit
a1d4ee2287
12
main.go
12
main.go
|
@ -89,12 +89,12 @@ func save(raw string, lang string, title string, expiry string) []string {
|
||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
sha := hash(raw)
|
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)
|
||||||
for query.Next() {
|
if err != sql.ErrNoRows {
|
||||||
var id, title, hash, paste, delkey string
|
for query.Next() {
|
||||||
err := query.Scan(&id, &title, &hash, &paste, &delkey)
|
var id, title, hash, paste, delkey string
|
||||||
check(err)
|
err := query.Scan(&id, &title, &hash, &paste, &delkey)
|
||||||
if hash == sha {
|
check(err)
|
||||||
url := ADDRESS + "/p/" + id
|
url := ADDRESS + "/p/" + id
|
||||||
return []string{id, title, hash, url, paste, delkey}
|
return []string{id, title, hash, url, paste, delkey}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue