diff --git a/g/database/gdb/gdb_structure.go b/g/database/gdb/gdb_structure.go index f88a7dcb9..e1c81f1ea 100644 --- a/g/database/gdb/gdb_structure.go +++ b/g/database/gdb/gdb_structure.go @@ -8,20 +8,19 @@ package gdb import ( "fmt" + "strings" + "github.com/gogf/gf/g/text/gregex" "github.com/gogf/gf/g/util/gconv" - "strings" ) -/* -// 同步数据库表结构到内存中 -func (bs *dbBase) syncTableStructure() { - bs.tables = make(map[string]map[string]string) - for _, table := range bs.db.getTables() { - bs.tables[table], _ = bs.db.getTableFields(table) - } -} -*/ +//// 同步数据库表结构到内存中 +//func (bs *dbBase) syncTableStructure() { +// bs.tables = make(map[string]map[string]string) +// for _, table := range bs.db.getTables() { +// bs.tables[table], _ = bs.db.getTableFields(table) +// } +//} // 字段类型转换,将数据库字段类型转换为golang变量类型 func (bs *dbBase) convertValue(fieldValue interface{}, fieldType string) interface{} { @@ -31,7 +30,7 @@ func (bs *dbBase) convertValue(fieldValue interface{}, fieldType string) interfa case "binary", "varbinary", "blob", "tinyblob", "mediumblob", "longblob": return gconv.Bytes(fieldValue) - case "bit", "int", "tinyint", "small_int", "medium_int": + case "int", "tinyint", "small_int", "medium_int": return gconv.Int(fieldValue) case "big_int": @@ -40,7 +39,7 @@ func (bs *dbBase) convertValue(fieldValue interface{}, fieldType string) interfa case "float", "double", "decimal": return gconv.Float64(fieldValue) - case "bool": + case "bit", "bool": return gconv.Bool(fieldValue) default: diff --git a/geg/database/gdb/mssql/config.toml b/geg/database/gdb/mssql/config.toml new file mode 100644 index 000000000..8e44ef003 --- /dev/null +++ b/geg/database/gdb/mssql/config.toml @@ -0,0 +1,8 @@ + +[database] + type = "mssql" + host = "116.255.140.92" + port = "1451" + user = "sa" + pass = "eno@123" + name = "frpc" diff --git a/geg/database/gdb/mssql/gdb_all.go b/geg/database/gdb/mssql/gdb_all.go new file mode 100644 index 000000000..ad4c5806d --- /dev/null +++ b/geg/database/gdb/mssql/gdb_all.go @@ -0,0 +1,14 @@ +package main + +import ( + "fmt" + + //_ "github.com/denisenkom/go-mssqldb" + "github.com/gogf/gf/g" +) + +func main() { + r, err := g.DB().GetAll(`SELECT * FROM (SELECT TOP 10 * FROM (SELECT TOP 10 * FROM KF_PatInfo_Emergency WHERE Report_BZ = 1 AND Examine_BZ = 0 ) as TMP1_ ) as TMP2_`) + fmt.Println(err) + g.Dump(r.ToList()) +}