class PropelPager implements Countable, Iterator
PropelPager
Example Usage:
require_once 'propel/util/PropelPager.php';
require_once 'PEACH/Propel/Poem/poemPeer.php';
$c = new Criteria();
$c->addDescendingOrderByColumn(poemPeer::SID);
// with join
$pager = new PropelPager($c, 'poemPeer', 'doSelectJoinPoemUsers', 1, 50);
// without Join
$pager = new PropelPager($c, 'poemPeer', 'doSelect', 1, 50);
Some template:
<p>
Total Pages: <?=$pager->getTotalPages()?> Total Records: <?=$pager->getTotalRecordCount()?>
</p>
<table>
<tr>
<td>
<?if ($link = $pager->getFirstPage):?>
<a href="somescript?page=<?=$link?>"><?=$link?></a>|
<?endif?>
</td>
<td>
<?if ($link = $pager->getPrev()):?>
<a href="somescript?page=<?=$link?>">Previous</a>|
<?endif?>
</td>
<td>
<?foreach ($pager->getPrevLinks() as $link):?>
<a href="somescript?page=<?=$link?>"><?=$link?></a>|
<?endforeach?>
</td>
<td><?=$pager->getPage()?></td>
<td>
<?foreach ($pager->getNextLinks() as $link):?>
| <a href="somescript?page=<?=$link?>"><?=$link?></a>
<?endforeach?>
</td>
<td>
<?if ($link = $pager->getNext()):?>
<a href="somescript?page=<?=$link?>">Last</a>|
<?endif?>
</td>
<td>
<?if ($link = $pager->getLastPage()):?>
<a href="somescript?page=<?=$link?>"><?=$link?></a>|
<?endif?>
</td>
</tr>
</table>
<table id="latestPoems">
<tr>
<th>Title</th>
<th>Auteur</th>
<th>Date</th>
<th>comments</th>
</tr>
<?foreach ($pager->getResult() as $poem):?>
<tr>
<td><?=$poem->getTitle()?></td>
<td><?=$poem->getPoemUsers()->getUname()?></td>
<td><?=$poem->getTime()?></td>
<td><?=$poem->getComments()?></td>
</tr>
<?endforeach?>
</table>
Methods
__construct(Criteria $c = null, string $peerClass = null, string $peerSelectMethod = null, int $page = 1, int $rowsPerPage = 25)
Create a new Propel Pager. |
||
void |
setCriteria(Criteria $c)
Set the criteria for this pager. |
|
Criteria |
getCriteria()
Return the Criteria object for this pager. |
|
void |
setPeerClass(string $class)
Set the Peer Classname |
|
string |
getPeerClass()
Return the Peer Classname. |
|
void |
setPeerMethod(string $method)
Set the Peer select method. |
|
string |
getPeerMethod()
Return the Peer select method. |
|
void |
setPeerSelectMethod(string $method)
Set the Peer select method. |
|
string |
getPeerSelectMethod()
Return the Peer select method. |
|
setPeerCountMethod(string $method)
Sets the Count method. |
||
getPeerCountMethod()
Return the Peer count method. |
||
mixed |
getResult()
Get the paged resultset |
|
int |
getFirstPage()
Get the first page |
|
boolean |
atFirstPage()
Convenience method to indicate whether current page is the first page. |
|
int |
getLastPage()
Get last page |
|
boolean |
atLastPage()
Convenience method to indicate whether current page is the last page. |
|
int |
getTotalPages()
get total pages |
|
array |
getPrevLinks(int $range = 5)
get an array of previous id's |
|
array |
getNextLinks(int $range = 5)
get an array of next id's |
|
bool |
isLastPageComplete()
Returns whether last page is complete |
|
mixed |
getPrev()
get previous id |
|
mixed |
getNext()
get next id |
|
void |
setPage(int $page)
Set the current page number (First page is 1). |
|
int |
getPage()
Get current page. |
|
setRowsPerPage(int $r)
Set the number of rows per page. |
||
int |
getRowsPerPage()
Get number of rows per page. |
|
int |
getTotalRecordCount()
Gets the total number of (un-LIMITed) records. |
|
setStart(int $v)
Sets the start row or offset. |
||
void |
setMax(int $v)
Sets max rows (limit). |
|
int |
count()
Returns the count of the current page's records |
|
mixed |
current()
Returns the current element of the iterator |
|
int |
key()
Returns the current key of the iterator |
|
void |
next()
Advances the iterator to the next element |
|
void |
rewind()
Resets the iterator to the first element |
|
boolean |
valid()
Checks if the current key exists in the container |
Details
at line 123
public
__construct(Criteria $c = null, string $peerClass = null, string $peerSelectMethod = null, int $page = 1, int $rowsPerPage = 25)
Create a new Propel Pager.
at line 141
public void
setCriteria(Criteria $c)
Set the criteria for this pager.
at line 150
public Criteria
getCriteria()
Return the Criteria object for this pager.
at line 161
public void
setPeerClass(string $class)
Set the Peer Classname
at line 170
public string
getPeerClass()
Return the Peer Classname.
at line 183
public void
setPeerMethod(string $method)
Set the Peer select method.
This exists for legacy support, please use setPeerSelectMethod().
at line 195
public string
getPeerMethod()
Return the Peer select method.
This exists for legacy support, please use getPeerSelectMethod().
at line 206
public void
setPeerSelectMethod(string $method)
Set the Peer select method.
at line 215
public string
getPeerSelectMethod()
Return the Peer select method.
at line 226
public
setPeerCountMethod(string $method)
Sets the Count method.
This is set based on the Peer method, for example if Peer method is doSelectJoin*() then the
count method will be doCountJoin*().
at line 234
public
getPeerCountMethod()
Return the Peer count method.
at line 263
public mixed
getResult()
Get the paged resultset
at line 294
public int
getFirstPage()
Get the first page
For now I can only think of returning 1 always.
It should probably return 0 if there are no pages
at line 304
public boolean
atFirstPage()
Convenience method to indicate whether current page is the first page.
at line 314
public int
getLastPage()
Get last page
at line 329
public boolean
atLastPage()
Convenience method to indicate whether current page is the last page.
at line 339
public int
getTotalPages()
get total pages
at line 359
public array
getPrevLinks(int $range = 5)
get an array of previous id's
at line 382
public array
getNextLinks(int $range = 5)
get an array of next id's
at line 404
public bool
isLastPageComplete()
Returns whether last page is complete
at line 414
public mixed
getPrev()
get previous id
at line 430
public mixed
getNext()
get next id
at line 446
public void
setPage(int $page)
Set the current page number (First page is 1).
at line 457
public int
getPage()
Get current page.
at line 466
public
setRowsPerPage(int $r)
Set the number of rows per page.
at line 477
public int
getRowsPerPage()
Get number of rows per page.
at line 498
public int
getTotalRecordCount()
Gets the total number of (un-LIMITed) records.
This method will perform a query that executes un-LIMITed query.
at line 528
public
setStart(int $v)
Sets the start row or offset.
at line 538
public void
setMax(int $v)
Sets max rows (limit).
at line 547
public int
count()
Returns the count of the current page's records
at line 556
public mixed
current()
Returns the current element of the iterator
at line 569
public int
key()
Returns the current key of the iterator
at line 578
public void
next()
Advances the iterator to the next element
at line 587
public void
rewind()
Resets the iterator to the first element
at line 596
public boolean
valid()
Checks if the current key exists in the container