PHP Drupal函数返回数据库表的内容(用于调试)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP Drupal函数返回数据库表的内容(用于调试)相关的知识,希望对你有一定的参考价值。
function helpers_database_render_table($table_name) {
$columns = $header = $rows = array();
$result = db_queryd('SHOW columns in {%s}', $table_name);
while ($column = db_fetch_object($result)) {
$header[] = t('@columnname (@columntype)', array('@columnname' => $column->Field, '@columntype' => $column->Type));
$columns[] = $column->Field;
}
$result = pager_query('SELECT * FROM {%s}', 50, 0, NULL, $table_name);
while ($record = db_fetch_object($result)) {
foreach($columns as $column) {
//@TODO: include spans with title=fullresult on large results, and add ellipses in that case.
$row[$column] = drupal_substr($record->$column, 0, 36);
}
$rows[] = $row;
}
$count = db_result(db_query("SELECT count(%s) FROM {%s}", $columns[0], $table_name));
$caption = t('SELECT * FROM {%table_name} resulted in %count results', array('%table_name' => $table_name, '%count' => $count));
return theme('table', $header, $rows, array(), $caption) . theme('pager');
}
以上是关于PHP Drupal函数返回数据库表的内容(用于调试)的主要内容,如果未能解决你的问题,请参考以下文章
自定义字段的drupal主题化视图:PHP代码
如何从外部PHP文件运行Drupal 8函数
Drupal 数据库性能调优——将特定表从 MyISAM 切换到 InnoDB
php设计api,只能以echo的形式返回给调用者吗?为啥用return就不能返回数据呢?
php Drupal 8返回缓存的REST数据
设置Drupal附件表的主题