dongzhouji4021 2013-10-30 11:49
浏览 57
已采纳

Mustache PHP - 如何从数据库加载数据?

In Mustache data is loaded from. json static files and I can't understand how can I load data from a MySQL DB.

Example: currently the data contained in the "partials" are loaded from a .json file but, of course, whatever application needs to load data from a database in dynamic way (mysql in my case).

How can I do?

Thanks in advance!

Giovanni

  • 写回答

2条回答 默认 最新

  • dpus81500574 2013-10-30 12:08
    关注

    Mustache PHP is only a templating engine. It's not an entire application with ready to go database bindings.

    You need to write an application that instantiates Moustache templates and gives the necessary data.

    $m = new Mustache_Engine;
    echo $m->render(
             'Hello {{planet}}',
             array('planet' => 'World!')
         ); // "Hello World!"
    

    The array with the planet=> 'World!' values is the data being passed to Moustache (in this case). You can load that data from a database and pass it to moustache as a variable.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面