Zend_Db_Table关系和Zend_Paginator

时间:2021-01-31 11:11:42

is there a way, hot to apply paginator limit on select, which I send to findDependentRowset function? for example:

有没有办法,热选择应用paginator限制,我发送到findDependentRowset函数?例如:

$select = $row->select();
$select->order('item_name');    
$row->findDependentRowset($table, null, $select)

thank's

2 个解决方案

#1


You need just add limit to your select passed to findDependentRowset. It will look like this:

您只需要为传递给findDependentRowset的select添加限制。它看起来像这样:

$select = $row->select()->limit($itemCountPerPage,$offset);
$select->order('item_name');    
$row->findDependentRowset($table, null, $select);

#2


this looks good, but paginator will don't have information about all rows count. I found solution to override Zend_Paginator_Adapter_DbSelect and set function

这看起来不错,但是paginator将没有关于所有行数的信息。我找到了覆盖Zend_Paginator_Adapter_DbSelect和设置函数的解决方案

public function getItems($offset, $itemCountPerPage)
{
   $this->_select->limit($itemCountPerPage, $offset);
   return $this->_select;
}

this will return select with applied limit and I can use Paginator with its whole funcionality

这将返回带有应用限制的选择,我可以使用Paginator及其整个功能

#1


You need just add limit to your select passed to findDependentRowset. It will look like this:

您只需要为传递给findDependentRowset的select添加限制。它看起来像这样:

$select = $row->select()->limit($itemCountPerPage,$offset);
$select->order('item_name');    
$row->findDependentRowset($table, null, $select);

#2


this looks good, but paginator will don't have information about all rows count. I found solution to override Zend_Paginator_Adapter_DbSelect and set function

这看起来不错,但是paginator将没有关于所有行数的信息。我找到了覆盖Zend_Paginator_Adapter_DbSelect和设置函数的解决方案

public function getItems($offset, $itemCountPerPage)
{
   $this->_select->limit($itemCountPerPage, $offset);
   return $this->_select;
}

this will return select with applied limit and I can use Paginator with its whole funcionality

这将返回带有应用限制的选择,我可以使用Paginator及其整个功能