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