我无法弄明白:(
完整的脚本......
故障线由“此线”标注 我可以把它们拿出来,脚本可以工作但只有一半:(
require_once("global.php");
$kernel->vars['page_struct']['system_page_action_title'] = $kernel->ld['phrase_page_title_statistics'];
// No categories in archive
if ($kernel->db->numrows("SELECT `category_id` FROM `" . TABLE_PREFIX . "categories`") == 0) {
$kernel->page->message_report($kernel->ld['phrase_no_categories'], M_NOTICE);
}
else {
$kernel->tp->call("page_statistics");
$kernel->vars['stats'] = array();
// Archive Highs
// This line.
$kernel->vars['stats'] = $kernel->vars['stats'] + $kernel->db->row("SELECT `file_id` AS `latest_file_id`, `file_name` AS `latest_file_name`, `file_timestamp` AS `latest_file_timestamp` FROM `" . TABLE_PREFIX . "files` ORDER BY `file_id` DESC LIMIT 1");
$kernel->vars['stats']['latest_file_timestamp'] = $kernel->fetch_time($kernel->vars['stats']['latest_file_timestamp'], DF_SHORT);
// This line.
$kernel->vars['stats'] = $kernel->vars['stats'] + $kernel->db->row("SELECT `file_id` AS `mostdl_file_id`, `file_name` AS `mostdl_file_name`, `file_downloads` AS `mostdl_file_downloads` FROM `" . TABLE_PREFIX . "files` ORDER BY `file_downloads` DESC LIMIT 1");
$kernel->vars['stats']['mostdl_file_downloads'] = $kernel->vars['stats']['mostdl_file_downloads'];
// This line.
$kernel->vars['stats'] = $kernel->vars['stats'] + $kernel->db->row("SELECT `file_id` AS `leastdl_file_id`, `file_name` AS `leastdl_file_name`, `file_downloads` AS `leastdl_file_downloads` FROM `" . TABLE_PREFIX . "files` ORDER BY `file_downloads` ASC LIMIT 1");
$kernel->vars['stats']['leastdl_file_downloads'] = $kernel->vars['stats']['leastdl_file_downloads'];
// This line.
$kernel->vars['stats'] = $kernel->vars['stats'] + $kernel->db->row("SELECT `file_id` AS `highrate_file_id`, `file_name` AS `highrate_file_name`, `file_rating` AS `highrate_file_rating`, `file_votes` AS `highrate_file_votes` FROM `" . TABLE_PREFIX . "files` ORDER BY `file_rating` DESC, `file_votes` DESC LIMIT 1");
$kernel->vars['stats']['highrate_file_rank'] = $kernel->archive->construct_file_rating($kernel->vars['stats']['highrate_file_rating'], $kernel->vars['stats']['highrate_file_votes']);
// Datastore counters
$datastore_keys = array("total_announcements", "total_files", "total_categories", "total_users", "total_downloads", "total_votes", "total_images", "total_comments");
foreach($datastore_keys AS $counter) {
$kernel->vars['stats']["$counter"] = $kernel->format_input($kernel->db->item("SELECT `datastore_value` FROM `" . TABLE_PREFIX . "datastore` WHERE `datastore_key` = 'count_" . $counter . "'"), T_NUM);
}
$kernel->ld['phrase_statistics_message'] = sprintf($kernel->ld['phrase_statistics_message'], $kernel->fetch_time($kernel->config['archive_start'], DF_SHORT), $kernel->archive->format_round_bytes($kernel->db->item("SELECT `datastore_value` FROM `" . TABLE_PREFIX . "datastore` WHERE `datastore_key` = 'count_total_data'")));
$kernel->tp->cache($kernel->vars['stats']);
}
$kernel->page->construct_output(R_HEADER, R_FOOTER, false, R_NAVIGATION);
答案 0 :(得分:2)
$kernel->db->row
是一个数组吗?我想这是一个对象,你不能添加对象和数组。
答案 1 :(得分:2)
我们知道$kernel->vars['stats']
是一个数组,因为:
$kernel->vars['stats'] = array();
接下来是您的问题:
$kernel->vars['stats']=$kernel->vars['stats'] + $kernel->db->row( ... );
+
表示2个数组的并集,因此$kernel->db->row(...)
必须是数组。
答案 2 :(得分:0)
您好像期待一个数组作为row
方法的返回值。不知道你的DB类,我们不能说这是否属实,但无论如何,你应该首先检查返回类型。 (也是出于错误的情况)
$row = $kernel->db->row( "SELECT `file_id` .... " );
if (is_array($row))
$kernel->vars['stats'] = $kernel->vars['stats'] + $row;