mirror of
https://gitee.com/johng/gf.git
synced 2024-12-02 12:17:53 +08:00
improve configuration for mssql
This commit is contained in:
parent
0317f6812e
commit
36403fdc08
@ -1,3 +1,3 @@
|
||||
|
||||
[database]
|
||||
linkinfo = "sqlserver://test:test1@122.152.202.91:1433?database=test"
|
||||
linkinfo = "mssql:user id=test;password=test1;server=122.152.202.91;port=1433;database=test;encrypt=disable"
|
@ -2,13 +2,22 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/os/gtime"
|
||||
|
||||
_ "github.com/denisenkom/go-mssqldb"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r, err := g.DB().GetAll(`SELECT TOP 10 * FROM KF_PatInfo_Emergency`)
|
||||
fmt.Println(err)
|
||||
g.Dump(r.ToList())
|
||||
type Table2 struct {
|
||||
Id string `orm:"id;pr" json:"id"` //ID
|
||||
Createtime gtime.Time `orm:"createtime" json:"createtime"` //创建时间
|
||||
Updatetime gtime.Time `orm:"updatetime" json:"updatetime"` //更新时间
|
||||
}
|
||||
var table2 Table2
|
||||
err := g.DB().Table("table2").Where("id=?", 1).Struct(&table2)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(table2.Createtime)
|
||||
}
|
||||
|
@ -255,16 +255,10 @@ func parseDBConfigNode(value interface{}) *gdb.ConfigNode {
|
||||
if node.LinkInfo != "" && node.Type == "" {
|
||||
match, _ := gregex.MatchString(`([a-z]+):(.+)`, node.LinkInfo)
|
||||
if len(match) == 3 {
|
||||
// Special handle for mssql for common usage purpose.
|
||||
if match[1] == "sqlserver" {
|
||||
node.Type = "mssql"
|
||||
node.LinkInfo = node.LinkInfo
|
||||
} else {
|
||||
node.Type = match[1]
|
||||
node.LinkInfo = match[2]
|
||||
}
|
||||
}
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
|
1
go.mod
1
go.mod
@ -5,6 +5,7 @@ go 1.11
|
||||
require (
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/clbanning/mxj v1.8.4
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e // indirect
|
||||
github.com/fatih/structs v1.1.0
|
||||
github.com/fsnotify/fsnotify v1.4.7
|
||||
github.com/gf-third/mysql v1.4.2
|
||||
|
@ -44,6 +44,16 @@ func Test_NewFromStr(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func Test_String(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
t1 := gtime.NewFromStr("2006-01-02 15:04:05")
|
||||
gtest.Assert(t1.String(), "2006-01-02 15:04:05")
|
||||
|
||||
t2 := *t1
|
||||
gtest.Assert(t2.String(), "2006-01-02 15:04:05")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_NewFromStrFormat(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
timeTemp := gtime.NewFromStrFormat("2006-01-02 15:04:05", "Y-m-d H:i:s")
|
||||
|
Loading…
Reference in New Issue
Block a user