数据库操作
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 c13da09c57 增加过滤 3 months ago
README.md 补充readme 3 years ago
chain.go 增加过滤 3 months ago
chain_test.go chain.go增加直接查询数据方法Get(),List() 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 init 3 years ago
prepare_test.go init 3 years ago
sqlserver.go 修改构造查询,兼容mssql的page size 1 year ago
transaction.go transaction bug修复 8 months ago
transaction_chain.go 增加过滤 3 months 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()