数据库操作
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 da0617d167 事务单条查询增加默认条件 1 month ago
README.md 补充readme 8 months ago
chain.go 修改find方法 6 months ago
chain_test.go 更新条件判断 8 months ago
conn.go 修改库连接操作 7 months ago
db.go init 8 months ago
db_test.go init 8 months ago
go.mod 更新条件判断 8 months ago
go.sum 增加链式操作 8 months ago
prepare.go init 8 months ago
prepare_test.go init 8 months ago
sqlserver.go 关闭sqlserver连接修改 7 months ago
transaction.go init 8 months ago
transaction_chain.go 事务单条查询增加默认条件 1 month 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()