开发者

Connecting to a database via Dwoo

I've just started learning the templating system Dwoo, and so far the basics are working (in regard to arrays).

However, I'm having troub开发者_高级运维le trying to get my pages to display content from a database. The official documentation has very little on it, as does Google.

What's your experience with Dwoo been like and has anyone on here tried this?


Dwoo is a templating engine, you shouldn't make database queries directly in it, it nullifies one of the main point of using a templating system.

You should make your database query in PHP:

$stmt = $pdo->prepare('SELECT * FROM table');
$stmt->execute();
$results = $pdo->fetchAll(PDO::FETCH_ASSOC);

Assign it to your template:

$dwoo = new Dwoo;
$dwoo->display('template.tpl', array('results'=>$results));

Then use it in the template:

{foreach from=$results item=result}
   do stuff
{/foreach}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜