- try to fix SQL_CALC_FOUND_ROWS (use transaction)

This commit is contained in:
gazebo
2018-09-15 23:04:46 +08:00
parent 04e105d8d1
commit a8ae37c641
3 changed files with 5 additions and 5 deletions

View File

@@ -183,12 +183,14 @@ func GetStores(keyword string, params map[string]interface{}, offset, pageSize i
sqlParams = append(sqlParams, pageSize, offset)
retVal = &StoresInfo{}
db := dao.GetDB()
dao.Begin(db)
if err = dao.GetRows(db, &retVal.Stores, sql, sqlParams...); err == nil {
countInfo := &struct{ Ct int }{}
if err = dao.GetRow(db, countInfo, "SELECT FOUND_ROWS() ct"); err == nil {
retVal.TotalCount = countInfo.Ct
}
}
dao.Commit(db)
return retVal, err
}