Bugfixes release of Zend Framework pagination component
By Geoffrey on Sunday 30 September 2007, 01:28 - Coding - Permalink
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.
Comments
The link to the code seems to be down :-(
Any chance you could post it on this server please?
monk.e.boy
Hi, I just uploaded the revision 122 to my own server:
http://fashion.hosmoz.net/public/pa...
Hi, i have problem using the component. I get Zend_Db_Statement_Exception (SQLSTATE42000: Syntax error or access violation:...).
I use this code in my controller:
$albums = new Riskle_Db_Table_Paginate(new Albums, $this->_getParam('page'));
$this->view->albums = $albums->fetchAll(null, 'title DESC');
$this->view->paginationInfos = $albums->getPaginationInfos();
And here is my albums class:
class Albums extends Riskle_Db_Table
{
protected $_name = 'albums';
}
So, could you please tell what is wrong with my code?