Version 1 by Tom Graham
on Sep 08, 2008 06:58.

compared with
Current by Matthew Ratzloff
on Oct 23, 2008 15:23.

This line was removed.
This word was removed. This word was added.
This line was added.

Changes (26)

View Page History
{info:title=New Proposal Template}
This page has been created from a template that uses "zones." To proceed:
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}

# Edit the page
# Replace sample content within each zone-data tag with your own content
# Remove this notice
# Save the page
# When you are ready for community review, move this page to the [Ready for Review] section on the edit page.

{note:title=No placeholders allowed!}
Please do not create placeholders. Wait until you have sufficient content to replace all sample data in the proposal template before creating your proposal document.

{zone-template-instance:ZFPROP:Proposal Zone Template}

Zend_Magic Zend_Paginator_Adapter_DbTable

[My Name|]
[Tom Graham|]

1.0 - 1 January 8 September 2008: Initial Draft.

Zend_Magic is a simple component that reads my mind and generates code dynamically to do what I want.
Zend_Paginator_Adapter_DbTable is an extension of Zend_Paginator_Adapter_DbSelect that allows a Zend_Db_Table_Rowset to be returned as the result of the paginator.

* [Harry Houdini Wikipedia Entry|]
* [|]
* [Example code and usage on my blog|]

* Zend_Paginator
* Zend_Paginator_Adapter_DbSelect
* Zend_Paginator_Adapter_Abstract
* Zend_Exception

The component is instantiated with a mind-link that ...
The same as DbSelect only a Zend_Db_Table_Rowset is returned.

* Zend_Magic_Exception Zend_Paginator_Adapter_DbTable
* Zend_Magic (factory class)
* Zend_Magic_MindProbe
* Zend_Magic_MindProbe_Intent
* Zend_Magic_Action
* Zend_Magic_CodeGen


... (see good use cases book)
$table = new Users();
$select = $table->select()->order('last_name ASC');
$paginator = new Zend_Paginator(Zend_Paginator_Adapter_DbTable($select, $table);

class Zend_Magic_Exception extends Zend_Exception {}
class Zend_Paginator_Adapter_DbTable extends Zend_Paginator_Adapter_DbSelect
* The table to select from
* @var Zend_Db_Table
protected $_table;

class Zend_Magic {
* Constructor.
* @param Zend_Db_Table_Select $select The select query
* @param Zend_Db_Table $table The table to select from
public function __construct(Zend_Db_Table_Select $select, Zend_Db_Table $table)
$this->_select = $select;
$this->_table = $table;
* Returns a rowset object
* @param integer $offset Page offset
* @param integer $itemCountPerPage Number of items per page
* @return Zend_Db_Table_Rowset
public function getItems($offset, $itemCountPerPage)
$this->_select->limit($itemCountPerPage, $offset);

return $this->_table->fetchAll($this->_select);

* Returns the total number of rows in the result set.
* @return integer
public function count()
if ($this->_rowCount === null) {
$expression = new Zend_Db_Expr('COUNT(*) AS ' . self::ROW_COUNT_COLUMN);

$rowCount = clone $this->_select;


return $this->_rowCount;