I am using sEcho from datatables post, iTotalRecords using row count before applying filters and limit in query and iTotalDisplayRecords as row count after applying filters and limit. aaData is the actual query result.
Code:
$iFilteredTotal = $result['filteredRecords'];
$iTotal = $result['totalRecords'];
// Output
$output = array ("sEcho" => intval ($_POST['sEcho']), "whichorders" => $member, "iTotalRecords" => $iTotal, "iTotalDisplayRecords" => $iFilteredTotal, "aaData" => $result['data']);
$out = json_encode ($output);
EDIT: It looks like the parameter names have been changed in the new datatables version but you get the idea.