ozzo-dbx icon indicating copy to clipboard operation
ozzo-dbx copied to clipboard

how can i get update rows

Open fancyecommerce opened this issue 7 years ago • 3 comments

db.Update("customer", dbx.Params{"name":json.Name, "age":json.Age}, dbx.HashExp{"id": userId}).Execute()

how can i get update rows

fancyecommerce avatar Jan 26 '18 07:01 fancyecommerce

如何得到更新的行数?

fancyecommerce avatar Feb 06 '18 01:02 fancyecommerce

Look at the description of Execute, it says Execute executes the SQL statement without retrieving data.

Use something like this: db.Update("customer", dbx.Params{"name":json.Name, "age":json.Age}, dbx.HashExp{"id": userId}).All(&m)

use either this: .All(), .One(), .Column(), .Row(), .Rows()

byanjiong avatar Feb 09 '18 07:02 byanjiong

@fancyecommerce You can use follow code

result, _:= db.Update("customer", dbx.Params{"name":json.Name, "age":json.Age}, dbx.HashExp{"id": userId}).Execute()
result.RowsAffected()

hiscaler avatar Aug 29 '18 02:08 hiscaler