skynoface
skynoface

Reputation: 45

Which is better parameter for paging (offset or pageNum)

for example

service use mysql

1、http://lll.ooo.nm/user?offset=0&count=10 first page

2、http://lll.ooo.nm/user?pageNum=1&pageCount=10 first page

client

use 1 offset=list.size

use 2 must maintain a var like 'pageNum',when load more pageNum++. and service must change is in (pageNum-1)*pageCount

Upvotes: 0

Views: 679

Answers (1)

Chandresh Tarasariya
Chandresh Tarasariya

Reputation: 49

offset is better way to do easily. 1. mysql Query should have use of LIMIT. 2. first time from requesting need to pass offset=0, mysql query should have LIMIT from offset to number of record per request, ex. 10,20 etc. and return new offset in service response so next service request offset parameter become offset=0 to offset=20 (if 20 record per request) 3.if there will be no more record then need to return offset=-1 in service response 4.check if offset=-1 then no need to request more because you reached end of list.

Upvotes: 1

Related Questions