zhenghaorong c13da09c57 | 3 months ago | |
---|---|---|
README.md | 3 years ago | |
chain.go | 3 months ago | |
chain_test.go | 3 years ago | |
conn.go | 1 year ago | |
db.go | 3 months ago | |
db_test.go | 2 years ago | |
go.mod | 3 years ago | |
go.sum | 3 years ago | |
prepare.go | 3 years ago | |
prepare_test.go | 3 years ago | |
sqlserver.go | 1 year ago | |
transaction.go | 8 months ago | |
transaction_chain.go | 3 months 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()