Zend Framework 2.0.5 - Pagination with Stored Procedure

For programming and general questions on Zend Framework

Zend Framework 2.0.5 - Pagination with Stored Procedure

Postby aashah on Fri Jan 04, 2013 8:41 am

Hi All,

I am working on Zend Framework 2.0.5 with MS-SQL as database and stored procedure. Here, I am getting list of albums with zend pagination through MS-SQL & Stored Procedure. In controller and model class code as follows,

Album Controller file :
Code: Select all
       $select = $this->getAlbumTable()->getAlbumSelect(LOGGEDIN_USER_ID);
       $matches = $this->getEvent()->getRouteMatch();
       $page      = $matches->getParam('page', 1);
       $paginator = new \Zend\Paginator\Paginator(new \Zend\Paginator\Adapter\DbSelect($select, $this->getAlbumTable()->getAdapter()));       
        return array(
        'albums' => $paginator,

Album Model file :

Code: Select all
    public function getAlbumSelect($user_id = 0)
        $results = $this->adapter->query("select * from album", Adapter::QUERY_MODE_PREPARE);
        return $results;

But above code is not working and giving me error as,

"Catchable fatal error: Argument 1 passed to Zend\Paginator\Adapter\DbSelect::__construct() must be an instance of Zend\Db\Sql\Select, instance of Zend\Db\Adapter\Driver\Sqlsrv\Statement given, called in D:\wamp\www\zf2_tutorial\module\Album\src\Album\Controller\AlbumController.php on line 54 and defined in D:\wamp\www\zf2_tutorial\vendor\zendframework\zendframework\library\Zend\Paginator\Adapter\DbSelect.php on line 59"

# Can anyone please guide me where I am making mistake or how we can implement Zend Paggination with MS-SQL Stored Procedure on Zend Framework 2.0.5.

Thanks in advanced.

Ankit Shah.
Posts: 8
Joined: Thu Dec 20, 2012 2:26 pm

Return to Zend Framework

Who is online

Users browsing this forum: No registered users and 7 guests