Silverstripe 3 Pagination fix

So I was trying to paginate a custom search.

Hit a snag with some of the code recommended here:

if($records) {
$records = new PaginatedList($records, $this->request);

Problem being that Silverstripe throws a filthy error:
the method 'unlimitedrowcount' does not exist on 'DataList'

This is after fixing the following methods that no longer work in SS3:
setPageSize -> setPageLength
and setTotalSize -> setTotalItems

To fix the final problem, do another query without the limit in, call it $query2 then setTotalItems:


Its querying twice, so bit of a waste, but problem fixed for now.