Merge branch 'master' into qiangg_ghttp_graceful

This commit is contained in:
John
2018-05-07 17:50:11 +08:00
3 changed files with 4 additions and 4 deletions

View File

@ -362,7 +362,7 @@ func (db *Db) Update(table string, data interface{}, condition interface{}, args
// CURD操作:删除数据
func (db *Db) Delete(table string, condition interface{}, args ...interface{}) (sql.Result, error) {
return db.Exec(fmt.Sprintf("DELETE FROM %s WHERE %s", db.charl, table, db.charr, db.formatCondition(condition)), args...)
return db.Exec(fmt.Sprintf("DELETE FROM %s%s%s WHERE %s", db.charl, table, db.charr, db.formatCondition(condition)), args...)
}
// 格式化SQL查询条件

View File

@ -91,14 +91,14 @@ func (md *Model) Where(where interface{}, args...interface{}) (*Model) {
// 链式操作添加AND条件到Where中
func (md *Model) And(where interface{}, args...interface{}) (*Model) {
md.where += " AND " + md.db.formatCondition(where)
md.whereArgs = append(md.whereArgs, args)
md.whereArgs = append(md.whereArgs, args...)
return md
}
// 链式操作添加OR条件到Where中
func (md *Model) Or(where interface{}, args...interface{}) (*Model) {
md.where += " OR " + md.db.formatCondition(where)
md.whereArgs = append(md.whereArgs, args)
md.whereArgs = append(md.whereArgs, args...)
return md
}

View File

@ -478,7 +478,7 @@ func mapToStruct() {
}
func main() {
r, _ := db.Table("user").Fields("*").Where("typeid = ?", 1).Limit(0, 10).Select()
r, _ := db.Table("user").Fields("*").Where("typeid = ?", 1).And("uid=?", 1).Limit(0, 10).Select()
j, _ := gparser.VarToJson(r.ToList())
fmt.Println(string(j))
fmt.Println(r)