PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Structures » Structures_DataGrid » Bug #4416

Add "informative" functions to Core.php

Details

Request #4416Add "informative" functions to Core.php
Submitted2005-05-24 10:25 UTC
Frompost at mark-wiesemann dot de
StatusClosed
PackageStructures_DataGrid
PHP VersionIrrelevant
OSIrrelevant
Roadmaps(Not assigned)

Comments

[2005-05-24 10:25 UTC] post at mark-wiesemann dot de

Description:
------------
Sorry for having another feature request, but I think this is useful also for other users.

I'd like to add the following four functions to Core.php:
http://www.markwiesemann.de/php/SDG-Core-addition.phps

With these functions and the existing getCurrentPage() one can do something like this:

echo 'page ' . $dg->getCurrentPage() .
' from ' . $dg->getPageCount() .
', record ' . $dg->getCurrentRecordNumberStart() .
' to ' . $dg->getCurrentRecordNumberEnd() .
' from ' . $dg->getRecordCount();

Having 19 records and 10 records per page, the output would be:
- on the first page:
page 1 from 2, record 1 to 10 from 19
- on the second page:
page 2 from 2, record 11 to 19 from 19

Without a row limit the output would be:
page 1 from 1, record 1 to 19 from 19

If the record set is empty, the output would be:
page 1 from 1, record 0 to 0 from 0

In my opinion "page 0 from 0" would be better in this case, but getCurrentPage() currently returns 1 - so there would be a BC break (?).

I think I have tested all possible cases (empty record set, no row limit, row limit specified) with different DataSources (DBTable, DBQuery, Array) and got in every case the expected result as described above.