diff --git a/g/database/gdb/gdb_base.go b/g/database/gdb/gdb_base.go index 01ec77e2a..032bdbf23 100644 --- a/g/database/gdb/gdb_base.go +++ b/g/database/gdb/gdb_base.go @@ -308,7 +308,6 @@ func (db *Db) Begin() (*Tx, error) { func (db *Db) getInsertOperationByOption(option uint8) string { oper := "INSERT" switch option { - case OPTION_INSERT: case OPTION_REPLACE: oper = "REPLACE" case OPTION_SAVE: diff --git a/g/database/gdb/gdb_sqlite.go b/g/database/gdb/gdb_sqlite.go index 6c67da878..2dda7fe9c 100644 --- a/g/database/gdb/gdb_sqlite.go +++ b/g/database/gdb/gdb_sqlite.go @@ -44,6 +44,9 @@ func (db *dbsqlite) getQuoteCharRight() string { } // 在执行sql之前对sql进行进一步处理 +// @todo 需要增加对Save方法的支持,可使用正则来实现替换, +// @todo 将ON DUPLICATE KEY UPDATE触发器修改为两条SQL语句(INSERT OR IGNORE & UPDATE) func (db *dbsqlite) handleSqlBeforeExec(q *string) *string { + return q } diff --git a/geg/database/mysql/gdb.go b/geg/database/orm/mysql/gdb.go similarity index 100% rename from geg/database/mysql/gdb.go rename to geg/database/orm/mysql/gdb.go diff --git a/geg/database/mysql/gdb_cache.go b/geg/database/orm/mysql/gdb_cache.go similarity index 100% rename from geg/database/mysql/gdb_cache.go rename to geg/database/orm/mysql/gdb_cache.go diff --git a/geg/database/mysql/gdb_debug.go b/geg/database/orm/mysql/gdb_debug.go similarity index 100% rename from geg/database/mysql/gdb_debug.go rename to geg/database/orm/mysql/gdb_debug.go diff --git a/geg/database/mysql/gdb_json_xml.go b/geg/database/orm/mysql/gdb_json_xml.go similarity index 100% rename from geg/database/mysql/gdb_json_xml.go rename to geg/database/orm/mysql/gdb_json_xml.go diff --git a/geg/database/orm/sqlite/sqlite.go b/geg/database/orm/sqlite/sqlite.go new file mode 100644 index 000000000..8ee930bd1 --- /dev/null +++ b/geg/database/orm/sqlite/sqlite.go @@ -0,0 +1,47 @@ +package main + +//import ( +// _ "github.com/mattn/go-sqlite3" +// "gitee.com/johng/gf/g/database/gdb" +// "gitee.com/johng/gf/g" +// "fmt" +//) +// +//func main() { +// gdb.SetConfig(gdb.Config{ +// "default": gdb.ConfigGroup{ +// gdb.ConfigNode{ +// Name: "/tmp/my.db", +// Type: "sqlite", +// }, +// }, +// }) +// db := g.Database() +// if db == nil { +// panic("db create failed") +// } +// defer db.Close() +// +// // 创建表 +// sql := `CREATE TABLE user ( +// uid INT PRIMARY KEY NOT NULL, +// name VARCHAR(30) NOT NULL +// );` +// if _, err := db.Exec(sql); err != nil { +// fmt.Println(err) +// } +// +// // 写入数据 +// result, err := db.Table("user").Data(g.Map{"uid" : 1, "name" : "john"}).Save() +// if err == nil { +// fmt.Println(result.RowsAffected()) +// } else { +// fmt.Println(err) +// } +// +// // 删除表 +// sql = `DROP TABLE user;` +// if _, err := db.Exec(sql); err != nil { +// fmt.Println(err) +// } +//} \ No newline at end of file diff --git a/geg/other/test.go b/geg/other/test.go index ab813f9ee..744fb4fea 100644 --- a/geg/other/test.go +++ b/geg/other/test.go @@ -1,20 +1,9 @@ package main import ( - "fmt" - "gitee.com/johng/gf/g/os/gtime" + "fmt" ) func main() { - fmt.Println(gtime.Second()) - fmt.Println(gtime.Nanosecond()) - t := gtime.Millisecond() - for t < 1e18 { - t *= 10 - } - fmt.Println(t) - fmt.Println(int64(t/1e9)) - fmt.Println(t%1e9) - - fmt.Println(gtime.NewFromTimeStamp(t).Format("Y-m-d H:i:s.u")) -} + fmt.Println(1) +} \ No newline at end of file