码农笔录博客源码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 rivejä
476 B

6 vuotta sitten
package models
import (
4 vuotta sitten
"fmt"
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/server/web"
6 vuotta sitten
_ "github.com/go-sql-driver/mysql"
6 vuotta sitten
)
6 vuotta sitten
func RegistDB() {
dbUrl, _ := web.AppConfig.String("dburl")
4 vuotta sitten
fmt.Println(dbUrl)
orm.RegisterDriver("mysql", orm.DRMySQL)
orm.RegisterDataBase("default", "mysql", "root:"+dbUrl+"/beeblog?charset=utf8&loc=Local")
orm.RegisterModel(new(User), new(Blog), new(NLabel), new(Category))
4 vuotta sitten
orm.RunSyncdb("default", false, true)
6 vuotta sitten
}