gosora/gen_mysql.go

64 lines
1.9 KiB
Go
Raw Normal View History

/* This file was generated by Gosora's Query Generator */
package main
import "log"
import "database/sql"
var get_user_stmt *sql.Stmt
var get_full_user_stmt *sql.Stmt
var get_topic_stmt *sql.Stmt
var get_reply_stmt *sql.Stmt
var login_stmt *sql.Stmt
var get_password_stmt *sql.Stmt
var username_exists_stmt *sql.Stmt
func gen_mysql() (err error) {
if debug {
log.Print("Building the generated statements")
}
log.Print("Preparing get_user statement.")
get_user_stmt, err = db.Prepare("SELECT `name`,`group`,`is_super_admin`,`avatar`,`message`,`url_prefix`,`url_name`,`level` FROM users WHERE `uid`= ?")
if err != nil {
return err
}
log.Print("Preparing get_full_user statement.")
get_full_user_stmt, err = db.Prepare("SELECT `name`,`group`,`is_super_admin`,`session`,`email`,`avatar`,`message`,`url_prefix`,`url_name`,`level`,`score`,`last_ip` FROM users WHERE `uid`= ?")
if err != nil {
return err
}
log.Print("Preparing get_topic statement.")
get_topic_stmt, err = db.Prepare("SELECT `title`,`content`,`createdBy`,`createdAt`,`is_closed`,`sticky`,`parentID`,`ipaddress`,`postCount`,`likeCount` FROM topics WHERE `tid`= ?")
if err != nil {
return err
}
log.Print("Preparing get_reply statement.")
get_reply_stmt, err = db.Prepare("SELECT `content`,`createdBy`,`createdAt`,`lastEdit`,`lastEditBy`,`ipaddress`,`likeCount` FROM replies WHERE `rid`= ?")
if err != nil {
return err
}
log.Print("Preparing login statement.")
login_stmt, err = db.Prepare("SELECT `uid`,`name`,`password`,`salt` FROM users WHERE `name`= ?")
if err != nil {
return err
}
log.Print("Preparing get_password statement.")
get_password_stmt, err = db.Prepare("SELECT `password`,`salt` FROM users WHERE `uid`= ?")
if err != nil {
return err
}
log.Print("Preparing username_exists statement.")
username_exists_stmt, err = db.Prepare("SELECT `name` FROM users WHERE `name`= ?")
if err != nil {
return err
}
return nil
}