For those caring, I just posted some quick documentation for the pagination component at my assembla space. More docs will follow (including extensive phpdoc docblocks I hope).
A propos
- About me: Geoffrey Bachelet
- Profile LinkedIn
To content | To menu | To search
Monday 1 October 2007
By Geoffrey on Monday 1 October 2007, 12:44 - Coding
For those caring, I just posted some quick documentation for the pagination component at my assembla space. More docs will follow (including extensive phpdoc docblocks I hope).
Sunday 30 September 2007
By Geoffrey on Sunday 30 September 2007, 01:28 - Coding
I just released on riskle's assembla space a new version of my pagination component for the Zend Framework which you can download right now:
This release fixes a nasty bug in Riskle_Db_Table::fetchCols which prevented from retrieving the right count of cols involved in the query.
The table component has also been slightly rewritten following Erik's suggestion to move the parent mapping into _fetch. The parent mapping itself has been improved to allow "multi level" table joining. This will be best explained with an example:
Say you have three table, Foo, Bar and Quux, and you would like to execute the following query:
SELECT * FROM Foo JOIN Bar ON Foo.bar_id = Bar.id JOIN Quux ON Bar.quux_id = Quux.id
This is now possible with the following mapping (in Foo's class of course):
array(
'Bar' => array('local' => 'bar_id', 'remote' => 'id'),
'Quux' => array('local' => 'quux_id', 'remote' => 'Quux.id'),
);
Easy heh ?
As usual, any comments are appreciated, and please note that this code is released under the same license as the ZF itself, the new-bsd license.
Sunday 23 September 2007
By Geoffrey on Sunday 23 September 2007, 00:07 - Coding
UPDATE: new version (r105) available.
The component was given a little rewrite as expected, but maybe a little bit later than I would have wanted to :-) So it now has its own Rowclass proxy from which you can pull various infos such as current page, page range, next page, etc all exposed as getter methods (that is, getCurrentPage, getPageRange, getNextPage, etc), which you won't really have to worry about since the brand new view helper will take care of that for you. Usage has changed a little, bit, so let's first have a look at what's happening from the controller point of view:
$table = new Riskle_Db_Table_Paginate(new Table, $this->_getParam('page'));
$this->view->rowset = $table->fetchAll();
Not much changed here, except we don't need anymore to call getPaginationInfos(). Nice ! Now the big part, the view:
$this->paginate($this->rowset);
echo $this->paginate()->previous();
echo $this->paginate()->navigation();
echo $this->paginate()->next();
The view helper uses the neat composite helper trick from naneau - which is a really cool trick, great job naneau my fellow no-more-a-bunny. The first call inits the helper, feeding him the necessary rowset to work on, then you just have to call the methods you need to draw the navigation links. As you may expect, previous and next method will return nothing if no page is available (actually, they return their second argument, which defaults to an empty string).
Also, it's worth noting that the bundled Riskle_Db_Table features the patch from Erik, as well as a totally rewritten fetchCols method (now uses a straight Zend_Db_Select object instead of the ugly trick it used to use).
My code is no longer available on subversion, I moved the project to assembla. Instead ou can download this component from the riskle space's files board (direct download), the file contains all classes needed for the component to work, just unzip it in your include_path and you're set.
As usual, any comments are more than welcome.