这是我的查询:
class services extends Zend_Db_Table{
function Get_Services($user_id){
$DB = Zend_Db_Table_Abstract::getDefaultAdapter();
$select = $DB->select()
->from(array('p' => 'phone_service'))
->join(array('u' => 'user_preferences'), 'u.phone_service_id = p.phone_service_id')
->where('u.user_preferences_name = ?', 'is_user_package_active')
->where('p.user_id = ?', $user_id);
return $select;
}
}
这是我的控制器:
class ServicesController extends Zend_Controller_Action{
$instance = new services();
$select = $instance->Get_Services($user_id);
$adapter = new Zend_Paginator_Adapter_DbSelect($select);
$paginator = new Zend_Paginator($adapter);
$page=$this->_getParam('page',1);
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($page);
$paginator->setPagerange(5);
}
我正在做的是首先查询所有行,然后执行以下操作:
$adapter = new Zend_Paginator_Adapter_DbSelect($select);
$paginator = new Zend_Paginator($adapter);
我的问题是,我怎样才能优化它,使它只从结果中查询 10 行而不是全部?