/* This file was generated by Gosora's Query Generator */ // +build !pgsql !sqlite !mssql 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 var get_settings_stmt *sql.Stmt var get_setting_stmt *sql.Stmt var get_full_setting_stmt *sql.Stmt var is_plugin_active_stmt *sql.Stmt var get_users_stmt *sql.Stmt var is_theme_default_stmt *sql.Stmt var get_modlogs_stmt *sql.Stmt var get_reply_tid_stmt *sql.Stmt var get_topic_fid_stmt *sql.Stmt var get_user_reply_uid_stmt *sql.Stmt var has_liked_topic_stmt *sql.Stmt var get_topic_list_stmt *sql.Stmt var get_topic_user_stmt *sql.Stmt var get_topic_by_reply_stmt *sql.Stmt var get_topic_replies_stmt *sql.Stmt var get_forum_topics_stmt *sql.Stmt var get_profile_replies_stmt *sql.Stmt var create_topic_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 } log.Print("Preparing get_settings statement.") get_settings_stmt, err = db.Prepare("SELECT `name`,`content`,`type` FROM settings") if err != nil { return err } log.Print("Preparing get_setting statement.") get_setting_stmt, err = db.Prepare("SELECT `content`,`type` FROM settings WHERE `name` = ?") if err != nil { return err } log.Print("Preparing get_full_setting statement.") get_full_setting_stmt, err = db.Prepare("SELECT `name`,`type`,`constraints` FROM settings WHERE `name` = ?") if err != nil { return err } log.Print("Preparing is_plugin_active statement.") is_plugin_active_stmt, err = db.Prepare("SELECT `active` FROM plugins WHERE `uname` = ?") if err != nil { return err } log.Print("Preparing get_users statement.") get_users_stmt, err = db.Prepare("SELECT `uid`,`name`,`group`,`active`,`is_super_admin`,`avatar` FROM users") if err != nil { return err } log.Print("Preparing is_theme_default statement.") is_theme_default_stmt, err = db.Prepare("SELECT `default` FROM themes WHERE `uname` = ?") if err != nil { return err } log.Print("Preparing get_modlogs statement.") get_modlogs_stmt, err = db.Prepare("SELECT `action`,`elementID`,`elementType`,`ipaddress`,`actorID`,`doneAt` FROM moderation_logs") if err != nil { return err } log.Print("Preparing get_reply_tid statement.") get_reply_tid_stmt, err = db.Prepare("SELECT `tid` FROM replies WHERE `rid` = ?") if err != nil { return err } log.Print("Preparing get_topic_fid statement.") get_topic_fid_stmt, err = db.Prepare("SELECT `parentID` FROM topics WHERE `tid` = ?") if err != nil { return err } log.Print("Preparing get_user_reply_uid statement.") get_user_reply_uid_stmt, err = db.Prepare("SELECT `uid` FROM users_replies WHERE `rid` = ?") if err != nil { return err } log.Print("Preparing has_liked_topic statement.") has_liked_topic_stmt, err = db.Prepare("SELECT `targetItem` FROM likes WHERE `sentBy` = ? AND `targetItem` = ? AND `targetType` = 'topics'") if err != nil { return err } log.Print("Preparing get_topic_list statement.") get_topic_list_stmt, err = db.Prepare("SELECT `topics`.`tid`,`topics`.`title`,`topics`.`content`,`topics`.`createdBy`,`topics`.`is_closed`,`topics`.`sticky`,`topics`.`createdAt`,`topics`.`parentID`,`users`.`name`,`users`.`avatar` FROM topics LEFT JOIN users ON `topics`.`createdBy`=`users`.`uid` ORDER BY topics.sticky DESC,topics.lastReplyAt DESC,topics.createdBy DESC") if err != nil { return err } log.Print("Preparing get_topic_user statement.") get_topic_user_stmt, err = db.Prepare("SELECT `topics`.`title`,`topics`.`content`,`topics`.`createdBy`,`topics`.`createdAt`,`topics`.`is_closed`,`topics`.`sticky`,`topics`.`parentID`,`topics`.`ipaddress`,`topics`.`postCount`,`topics`.`likeCount`,`users`.`name`,`users`.`avatar`,`users`.`group`,`users`.`url_prefix`,`users`.`url_name`,`users`.`level` FROM topics LEFT JOIN users ON `topics`.`createdBy`=`users`.`uid` WHERE `tid` = ?") if err != nil { return err } log.Print("Preparing get_topic_by_reply statement.") get_topic_by_reply_stmt, err = db.Prepare("SELECT `topics`.`tid`,`topics`.`title`,`topics`.`content`,`topics`.`createdBy`,`topics`.`createdAt`,`topics`.`is_closed`,`topics`.`sticky`,`topics`.`parentID`,`topics`.`ipaddress`,`topics`.`postCount`,`topics`.`likeCount` FROM replies LEFT JOIN topics ON `replies`.`tid`=`topics`.`tid` WHERE `rid` = ?") if err != nil { return err } log.Print("Preparing get_topic_replies statement.") get_topic_replies_stmt, err = db.Prepare("SELECT `replies`.`rid`,`replies`.`content`,`replies`.`createdBy`,`replies`.`createdAt`,`replies`.`lastEdit`,`replies`.`lastEditBy`,`users`.`avatar`,`users`.`name`,`users`.`group`,`users`.`url_prefix`,`users`.`url_name`,`users`.`level`,`replies`.`ipaddress` FROM replies LEFT JOIN users ON `replies`.`createdBy`=`users`.`uid` WHERE `tid` = ?") if err != nil { return err } log.Print("Preparing get_forum_topics statement.") get_forum_topics_stmt, err = db.Prepare("SELECT `topics`.`tid`,`topics`.`title`,`topics`.`content`,`topics`.`createdBy`,`topics`.`is_closed`,`topics`.`sticky`,`topics`.`createdAt`,`topics`.`lastReplyAt`,`topics`.`parentID`,`users`.`name`,`users`.`avatar` FROM topics LEFT JOIN users ON `topics`.`createdBy`=`users`.`uid` WHERE `topics`.`parentID` = ? ORDER BY topics.sticky DESC,topics.lastReplyAt DESC,topics.createdBy DESC") if err != nil { return err } log.Print("Preparing get_profile_replies statement.") get_profile_replies_stmt, err = db.Prepare("SELECT `users_replies`.`rid`,`users_replies`.`content`,`users_replies`.`createdBy`,`users_replies`.`createdAt`,`users_replies`.`lastEdit`,`users_replies`.`lastEditBy`,`users`.`avatar`,`users`.`name`,`users`.`group` FROM users_replies LEFT JOIN users ON `users_replies`.`createdBy`=`users`.`uid` WHERE `users_replies`.`uid` = ?") if err != nil { return err } log.Print("Preparing create_topic statement.") create_topic_stmt, err = db.Prepare("INSERT INTO topics(`parentID`,`title`,`content`,`parsed_content`,`createdAt`,`lastReplyAt`,`ipaddress`,`words`,`createdBy`) VALUES (?,?,?,?,NOW(),NOW(),?,?,?)") if err != nil { return err } return nil }