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

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

Key
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.
{note}
{info}

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

{zone-data:component-name}
Zend_Magic Zend_Paginator_Adapter_DbTable
{zone-data}

{zone-data:proposer-list}
[My Name|mailto:noreply@zend.com]
[Tom Graham|mailto:me@noginn.com]
{zone-data}


{zone-data:revision}
1.0 - 1 January 8 September 2008: Initial Draft.
{zone-data}

{zone-data:overview}
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.
{zone-data}

{zone-data:references}
* [Harry Houdini Wikipedia Entry|http://en.wikipedia.org/wiki/Harry_Houdini]
* [MagicTricks.com|http://www.magictricks.com/]
* [Example code and usage on my blog|http://www.noginn.com/2008/08/25/zend_paginator-and-zend_db_table/]
{zone-data}


{zone-data:dependencies}
* Zend_Paginator
* Zend_Paginator_Adapter_DbSelect
* Zend_Paginator_Adapter_Abstract
* Zend_Exception
{zone-data}

{zone-data:operation}
The component is instantiated with a mind-link that ...
The same as DbSelect only a Zend_Db_Table_Rowset is returned.
{zone-data}


{zone-data:class-list}
* Zend_Magic_Exception Zend_Paginator_Adapter_DbTable
* Zend_Magic (factory class)
* Zend_Magic_MindProbe
* Zend_Magic_MindProbe_Intent
* Zend_Magic_Action
* Zend_Magic_CodeGen
{zone-data}

{zone-data:use-cases}
||UC-01||

... (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);
{zone-data}

{zone-data:skeletons}
{code}
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;
$rowCount->from($this->_table)
->reset(Zend_Db_Select::COLUMNS)
->reset(Zend_Db_Select::ORDER)
->reset(Zend_Db_Select::LIMIT_OFFSET)
->columns($expression);

$this->setRowCount($rowCount);
}

return $this->_rowCount;
}
}
{code}
{zone-data}

{zone-template-instance}
{zone-template-instance}]]></ac:plain-text-body></ac:macro>