package dbUtil

import (
	"fmt"
	"log"

	"github.com/astaxie/beego"
	_ "github.com/go-sql-driver/mysql"
	"github.com/go-xorm/xorm"
)

var Engine *xorm.Engine

func init() {
	fmt.Println("进来db")
	u := beego.AppConfig.String("mysqluser")
	p := beego.AppConfig.String("mysqlpass")
	url := beego.AppConfig.String("mysqlurls")
	dbname := beego.AppConfig.String("mysqldb")
	port := beego.AppConfig.String("mysqlport")
	/*orm.RegisterDataBase("vote", "mysql", u+":"+p+"@tcp("+url+":+"+port+")/"+dbname+"?charset=utf8")
	orm.RegisterModel(new(model.VVoteInfo))*/
	var err error
	Engine, err = xorm.NewEngine("mysql", u+":"+p+"@tcp("+url+":+"+port+")/"+dbname+"?charset=utf8")
	if err != nil {
		log.Fatal("错误=", err)
	}
}
