2018-05-16 10:46:14 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "database/sql"
|
2018-10-27 03:21:02 +00:00
|
|
|
import "github.com/Azareal/Gosora/query_gen"
|
2018-05-16 10:46:14 +00:00
|
|
|
|
|
|
|
func execStmt(stmt *sql.Stmt, err error) error {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
_, err = stmt.Exec()
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
/*func eachUserQuick(handle func(int)) error {
|
|
|
|
stmt, err := qgen.Builder.Select("users").Orderby("uid desc").Limit(1).Prepare()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
var topID int
|
|
|
|
err := stmt.QueryRow(topID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := 1; i <= topID; i++ {
|
|
|
|
err = handle(i)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
|
|
|
|
func eachUser(handle func(int) error) error {
|
2019-04-13 11:54:22 +00:00
|
|
|
err := qgen.NewAcc().Select("users").Cols("uid").Each(func(rows *sql.Rows) error {
|
2018-05-16 10:46:14 +00:00
|
|
|
var uid int
|
|
|
|
err := rows.Scan(&uid)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return handle(uid)
|
|
|
|
})
|
|
|
|
return err
|
|
|
|
}
|