【发布时间】:2019-10-20 11:01:36
【问题描述】:
谁能建议我如何在 .tpl 文件中编写 SQL 查询?
我试着写 db_select('node', 'n');但这不是最好的方法!我试着在 template.php 中写这个但不工作!
我的代码在 tpl 中运行良好!
请给我一个在tpl文件中编写sql查询的解决方案
我的查询:
$node = $variables['node'];
$author = user_load($node->uid);
$query = db_select('node', 'n')
->condition('n.uid', $author->uid, '=')
->condition('type', 'agahi');
$count_query = $query->countQuery()->execute()->fetchField();
print $count_query;
【问题讨论】:
标签: drupal-7 drupal-modules drupal-theming