更新指定字段
dao := NewDbtestDao()
param := torm.CastToParamIn([]int{1})
lists, err := dao.Get(param)
if err != nil {
return err
}
if len(lists) > 0 {
row := lists[0]
row.Param1 = 100
row.Param2 = "update1"
row.Param3 = "update1"
affect, err := dao.UpdateCols(&row, "param2", "param3")
}
- UpdateCols(&row, “param2”, “param3”)方法传入不定数量参数,参数为指定更新字段,需为表实际字段名