调整orm示例代码目录,sqlite增加todo提示

This commit is contained in:
john
2018-08-09 09:49:57 +08:00
parent 44c615ffae
commit 9bb481ea96
8 changed files with 53 additions and 15 deletions

View File

@ -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:

View File

@ -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
}

View File

@ -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)
// }
//}

View File

@ -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)
}