introduce order by
Cette révision appartient à :
Parent
daf5000507
révision
c0ba0d8e75
1 fichiers modifiés avec 4 ajouts et 4 suppressions
8
main.go
8
main.go
|
@ -51,7 +51,7 @@ func apiHandler(w http.ResponseWriter, r *http.Request) {
|
|||
page := vars["page"]
|
||||
pagenum, _ := strconv.Atoi(html.EscapeString(page))
|
||||
b := Record{Records: []Records{}}
|
||||
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents LIMIT 50 offset ?", 50*pagenum-1)
|
||||
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents ORDER BY torrent_id DESC LIMIT 50 offset ?", 50*pagenum-1)
|
||||
for rows.Next() {
|
||||
var id, name, hash, magnet string
|
||||
rows.Scan(&id, &name, &hash)
|
||||
|
@ -81,7 +81,7 @@ func singleapiHandler(w http.ResponseWriter, r *http.Request) {
|
|||
vars := mux.Vars(r)
|
||||
id := vars["id"]
|
||||
b := Record{Records: []Records{}}
|
||||
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents where torrent_id = ?", html.EscapeString(id))
|
||||
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents where torrent_id = ? ORDER BY torrent_id DESC", html.EscapeString(id))
|
||||
for rows.Next() {
|
||||
var id, name, hash, magnet string
|
||||
rows.Scan(&id, &name, &hash)
|
||||
|
@ -113,7 +113,7 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
|
|||
pagenum, _ := strconv.Atoi(html.EscapeString(page))
|
||||
param1 := r.URL.Query().Get("q")
|
||||
b := Record{Records: []Records{}}
|
||||
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents where torrent_name LIKE ? LIMIT 50 offset ?", "%"+html.EscapeString(param1)+"%", 50*pagenum-1)
|
||||
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents where torrent_name LIKE ? ORDER BY torrent_id DESC LIMIT 50 offset ?", "%"+html.EscapeString(param1)+"%", 50*pagenum-1)
|
||||
for rows.Next() {
|
||||
var id, name, hash, magnet string
|
||||
rows.Scan(&id, &name, &hash)
|
||||
|
@ -140,7 +140,7 @@ func rootHandler(w http.ResponseWriter, r *http.Request) {
|
|||
page := vars["page"]
|
||||
pagenum, _ := strconv.Atoi(html.EscapeString(page))
|
||||
b := Record{Records: []Records{}}
|
||||
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents LIMIT 50 offset ?", 50*pagenum-1)
|
||||
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents ORDER BY torrent_id DESC LIMIT 50 offset ?", 50*pagenum-1)
|
||||
for rows.Next() {
|
||||
var id, name, hash, magnet string
|
||||
rows.Scan(&id, &name, &hash)
|
||||
|
|
Référencer dans un nouveau ticket