$mongo = new MongoCdr(); $page = $_REQUEST['page']; // get the requested page $limit = $_REQUEST['rows']; // get how many rows we want to have into the grid $sidx = $_REQUEST['sidx']; // get index row - i.e. user click to sort $sord = $_REQUEST['sord']; // get the direction $sord = $sord == 'asc' ? 1 : -1; if (!$sidx) { $sidx = 1; } //$connection->dropDB('sip_mphill_com'); //192_168_50_229.1160 $db = $mongo->selectDB('cdr'); $collection = $db->selectCollection('record'); $domain = 'sip_mphill_com'; //search = array('domain' => $domain ) $count = $collection->find()->count(); // if ($count > 0) { $total_pages = @ceil($count / $limit); } else { $total_pages = 0; } if ($page > $total_pages) { $page = $total_pages; } $start = $limit * $page - $limit; // do not put $limit*($page - 1)