Added optional $useTotal variable to paginate

Using paginate with views in postgresql can be very slow, as it uses
count(*) to obtain the total number of rows. In a table this is fine,
since as of Postgres 9.2 Index-only scans can be used. However, if the
'table' is actually a view, this isn't possible and a sequential scan
will be done instead.

The $useTotal variable provides the option of obtaining the total in
some other manner (such as counting on one of the main tables) and then
using that for pagination.