数据库操作
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 53351218b4 修改查询方法 3 years ago
README.md 补充readme 3 years ago
chain.go 修改查询方法 3 years ago
chain_test.go 更新条件判断 3 years ago
conn.go init 3 years ago
db.go init 3 years ago
db_test.go init 3 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
transaction.go init 3 years 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()