2018-05-16 10:46:14 +00:00
|
|
|
package main
|
|
|
|
|
2022-02-21 03:53:13 +00:00
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
|
|
|
|
qgen "git.tuxpa.in/a/gosora/query_gen"
|
|
|
|
)
|
2018-05-16 10:46:14 +00:00
|
|
|
|
|
|
|
func execStmt(stmt *sql.Stmt, err error) error {
|
2022-02-21 03:53:13 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
_, err = stmt.Exec()
|
|
|
|
return err
|
2018-05-16 10:46:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*func eachUserQuick(handle func(int)) error {
|
2022-02-21 03:32:53 +00:00
|
|
|
stmt, err := qgen.Builder.Select("users").Orderby("uid desc").Limit(1).Prepare()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-05-16 10:46:14 +00:00
|
|
|
|
2022-02-21 03:32:53 +00:00
|
|
|
var topID int
|
|
|
|
err := stmt.QueryRow(topID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-05-16 10:46:14 +00:00
|
|
|
|
2022-02-21 03:32:53 +00:00
|
|
|
for i := 1; i <= topID; i++ {
|
|
|
|
err = handle(i)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2018-05-16 10:46:14 +00:00
|
|
|
}*/
|
|
|
|
|
|
|
|
func eachUser(handle func(int) error) error {
|
2022-02-21 03:53:13 +00:00
|
|
|
err := qgen.NewAcc().Select("users").Cols("uid").Each(func(rows *sql.Rows) error {
|
|
|
|
var uid int
|
|
|
|
err := rows.Scan(&uid)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return handle(uid)
|
|
|
|
})
|
|
|
|
return err
|
2018-05-16 10:46:14 +00:00
|
|
|
}
|