Skip to content

Commit eb4483f

Browse files
committed
adding pagination
1 parent 3ac1a51 commit eb4483f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

ws/server.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,20 @@
6060
break;
6161
case 'get':
6262
$r=[];
63+
$page=isset($_GET['page']) ? $_GET['page'] : 1;
64+
$limit=isset($_GET['limit']) ? $_GET['limit'] : 5;
65+
$rowInit=($limit*($page-1));
6366
try {
64-
$r['records'] = $pdoOne->select('ID,Players.Name,Country.Name as CountryName,IsActive')->from('Players')
67+
$result['records'] = $pdoOne->select('ID,Players.Name,Country.Name as CountryName,IsActive')
68+
->limit("$rowInit,$limit")
69+
->from('Players')
6570
->left('Country on Players.IdCounty=Country.IdCounty')->toList();
71+
$result['total']=count($result['records']);
6672
} catch (Exception $e) {
6773
$result=['result'=>false,'message'=>$e->getMessage()];
6874
}
69-
$r['total']=count($r['records']);
70-
echo json_encode($r);
75+
76+
echo json_encode($result);
7177
break;
7278
case 'countries':
7379
try {

0 commit comments

Comments
 (0)