douzoudang1511 2014-03-11 19:05
浏览 49
已采纳

如何创建自定义Zend Paginator适配器(Zend框架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?

  • 写回答

1条回答 默认 最新

  • dongyingjiu0669 2014-03-11 21:24
    关注

    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! :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
  • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
  • ¥100 描述一下元器件的基本功能,pcba板的基本原理
  • ¥15 STM32无法向设备写入固件
  • ¥15 使用ESP8266连接阿里云出现问题
  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果