1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| package dbops
import "log"
func ReadVideoDeletionRecord(count int) ([]string, error) { stmtOut, err := dbConn.Prepare("SELECT video_id FROM video_del_rec LIMIT ?") var ids []string if err != nil{ log.Printf("Prepare ReadVideoDeletionRecord error: %v\n", err) return nil, err }
rows, err := stmtOut.Query(count) if err != nil{ log.Printf("Query ReadVideoDeletionRecord error: %v\n", err) return nil, err } for rows.Next() { var id string if err := rows.Scan(&id); err != nil{ log.Printf("Scan ReadVideoDeletionRecord error: %v\n", err) return nil, err } log.Printf("get del video id: %s\n", id) ids = append(ids, id) } defer stmtOut.Close() return ids, nil }
func DelVideoDeltionRecord(vid string) error { stmtDel, err := dbConn.Prepare("DELETE FROM video_del_rec WHERE video_id = ?") if err != nil{ log.Printf("Prepare DelVideoDeltionRecord error: %v\n", err) return err }
_, err = stmtDel.Exec(vid) if err != nil{ log.Printf("Exec DelVideoDeltionRecord error: %v\n", err) return err }
defer stmtDel.Close() return nil }
|