phpmysqlzend-frameworkpaginationzend-paginator

How to create a custom Zend Paginator Adapter (Zend framework 1)


I'm working on implementing pagination with Zend framework 1.12, data mappers, and a mysql database.

I'm working off this example: http://akrabat.com/zend-framework/exploring-zend-paginator/ My question is how to create this with the zf tools. Specifically, I can create my adapter class by manually creating the files, but I get a fatal error that the adapter is not found. I think this has to do with the .zfproject.xml. Is there a zf command that I can use or how should I update the .zfproject.xml file?


Solution

  • Is your error regarding $ this-> getDbAdapter ()?
    If yes, try to replace $db = $this->getDbAdapter(); by

    $db = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('db') ;
    

    With in application.ini something like :

    resources.db.adapter = PDO_MYSQL
    resources.db.params.host = localhost
    resources.db.params.username = XXX
    resources.db.params.password = YYYY
    resources.db.params.dbname = db-name
    

    Regarding change .Zfproject.xml, I think it's a bad idea.
    The zf.bat is a tool box but if you want to do something more complicated, it is better not to use it and understand how Zend. (even if it is not necessarily obvious at first :))

    good luck! :)