Silverstripe 3 Pagination fix

So I was trying to paginate a custom search.

Hit a snag with some of the code recommended here:
http://doc.silverstripe.org/framework/en/reference/searchcontext

Namely:
if($records) {
$records = new PaginatedList($records, $this->request);
$records->setPageStart($start);
$records->setPageSize($limit);
$records->setTotalSize($query->unlimitedRowCount());
}

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:

$records->setTotalItems($query2->count());

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