数据库操作
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
zhenghaorong bb5a253e43 修改子查询带条件查询 1 year ago
README.md 补充readme 3 years ago
chain.go 添加子查询 1 year ago
chain_test.go chain.go增加直接查询数据方法Get(),List() 2 years ago
conn.go 增加从库查询 2 years ago
db.go 修改子查询带条件查询 1 year ago
db_test.go 增加分组功能 1 year ago
go.mod 尝试从读 2 years ago
go.sum 尝试从读 2 years ago
prepare.go init 3 years ago
prepare_test.go init 3 years ago
sqlserver.go 关闭sqlserver连接修改 3 years ago
transaction.go 修改子查询带条件查询 1 year ago
transaction_chain.go 添加子查询 1 year ago

README.md

dbquery

数据库操作

链式查询使用

查询单条记录
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()