数据库操作
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.
 
guzeng 6cc83234ed Merge branch 'master' of ssh://git.tetele.net:4001/tgo/dbquery 7 months ago
README.md 补充readme 3 years ago
chain.go 增加生成表名的函数 7 months ago
chain_test.go chain.go增加直接查询数据方法Get(),List() 2 years ago
conn.go 兼容多表名的情况 10 months ago
db.go 增加调试 7 months 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 修改构造查询,兼容mssql的page size 8 months ago
transaction.go 修改事务写入 1 year ago
transaction_chain.go 增加生成表名的函数 7 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()