zhenghaorong c13da09c57 | 1 month ago | |
---|---|---|
README.md | 3 years ago | |
chain.go | 1 month ago | |
chain_test.go | 2 years ago | |
conn.go | 1 year ago | |
db.go | 1 month ago | |
db_test.go | 2 years ago | |
go.mod | 2 years ago | |
go.sum | 2 years ago | |
prepare.go | 3 years ago | |
prepare_test.go | 3 years ago | |
sqlserver.go | 1 year ago | |
transaction.go | 6 months ago | |
transaction_chain.go | 1 month ago |
数据库操作
查询单条记录
map,err := new(Query).Db(dbname).Table(tablename).Where("id=?").Where("name=?").Value(1).Value("test").Find()
查询列表
list,err := new(Query).Db(dbname).Table(tablename).Where("id=?").Where("name=?").Value(1).Value("test").Select()
条件"或"
list,err := new(Query).Db(dbname).Table(tablename).Where("id=?").Where("name=?").WhereOr("mobile=?").Value(1).Value("test").Value("22").Select()
联表查
使用Join
list,err := new(Query).Db(dbname).Table(tablename).Join([]string{jointable,tablename.id=jointable.cid,"LEFT"}).Where("id=?").Where("name=?").Value(1).Value("test").Select()
更新
ret,err := new(Query).Db(dbname).Table(tablename).Data("name=?").Data("depart=?").Value("xxx").Value("test").Update()
插入
ret,err := new(Query).Db(dbname).Table(tablename).Data("name=?").Data("depart=?").Value("xxx").Value("test").Create()
删除
ret,err := new(Query).Db(dbname).Table(tablename).Where("name=?").Where("depart=?").Value("xxx").Value("test").Delete()