gpt4 book ai didi

php - PHP 5 中的输出缓冲和大型 MySQL 结果集

转载 作者:行者123 更新时间:2023-11-29 03:15:09 25 4
gpt4 key购买 nike

我正在尝试从具有巨大表格(几乎有 4k 条记录)的数据库构建 XML 提要。我想使用输出缓冲让它吐出 XML,但脚本仍然超时。

ob_start();
$what = 'j.*, (select description from tb_job_type as jt WHERE jt.jobtype_id = j.job_type_id) as job_type,';
$what .= '(select description from tb_location as l WHERE l.location_id = j.location_id) as location,';
$what .= '(select description from tb_industry as i WHERE i.industry_id = j.industry_id) as industry';
$where = ('' != $SelectedType) ? 'j.job_ad_type="' . $SelectedType .'"' : '';
$process = $db->executeQuery('SELECT ' . $what . ' FROM tb_job_ad as j' . $where);

while($result = mysql_fetch_array($process))
{
$result['job_title_url'] = $form->urlString($result['job_title']);
$result['job_title'] = htmlspecialchars($result['job_title'], ENT_QUOTES, 'UTF-8');
$result['short_description'] = htmlspecialchars($result['short_description'], ENT_QUOTES, 'UTF-8');
$result['full_description'] = htmlspecialchars($result['full_description'], ENT_QUOTES, 'UTF-8');
$result['company_name'] = ucwords(strtolower($result['company_name']));
$tpl->assignToBlock('ITEMS', $result);
}
$cheese = ob_get_contents();
$actualize = $tpl->actualize('FEED');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );
header("Cache-Control: no-cache, must-revalidate" );
header("Pragma: no-cache" );
header("Content-type: text/xml");
echo $actualize;
ob_flush();
print $cheese;
ob_end_clean();

这似乎是使脚本窒息的行:

$tpl->assignToBlock('ITEMS', $result);

请帮忙?

谢谢

米迪亚内。

最佳答案

会不会是你的查询比较慢?
比较

的输出
set_time_limit(60);
$process = $db->executeQuery('EXPLAIN SELECT ' . $what . ' FROM tb_job_ad as j' . $where);
while($result = mysql_fetch_array($process, MYSQL_ASSOC)) {
echo join(' | ', $result), "<br />\n";
}

Optimizing Queries with EXPLAIN .

关于php - PHP 5 中的输出缓冲和大型 MySQL 结果集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1426476/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com