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 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分