$psql=$empire->query("SELECT newstime,titleurl,classid,filename,newspath,id,groupid FROM {$dbtbpre}ecms_".$tbname." WHERE ".$where." AND checked=1 ORDER BY newstime DESC"); $flag=1;
$smaps="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\r\n";//sub
while($q=$empire->fetch($psql))
{
$titleurl=sys_ReturnBqTitleLink($q);
$smaps.="<url>\r\n<loc>".$titleurl."</loc>\r\n<priority>0.5</priority>\r\n<lastmod>".date('Y-m-d',$q[newstime])."</lastmod>\r\n</url>\r\n";
if($flag==1){$sitemap.="<lastmod>".date('Y-m-d',$q[newstime])."</lastmod>\r\n</sitemap>\r\n";}
$flag++;
}
$smaps.="</urlset>";
file_put_contents('../../xml/'.$xmlname.'', $smaps);
比如像上面这样的,假如表的数据很大,那么怎么样才能减轻服务器的负担?我看那些备份和恢复数据的都有2秒后继续的缓冲,应该怎么弄?
$smaps="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\r\n";//sub
while($q=$empire->fetch($psql))
{
$titleurl=sys_ReturnBqTitleLink($q);
$smaps.="<url>\r\n<loc>".$titleurl."</loc>\r\n<priority>0.5</priority>\r\n<lastmod>".date('Y-m-d',$q[newstime])."</lastmod>\r\n</url>\r\n";
if($flag==1){$sitemap.="<lastmod>".date('Y-m-d',$q[newstime])."</lastmod>\r\n</sitemap>\r\n";}
$flag++;
}
$smaps.="</urlset>";
file_put_contents('../../xml/'.$xmlname.'', $smaps);
比如像上面这样的,假如表的数据很大,那么怎么样才能减轻服务器的负担?我看那些备份和恢复数据的都有2秒后继续的缓冲,应该怎么弄?
$startnum , $perpage ");用 limit
if (file_exists('../../xml/cache.dat') && time() - filemtime('../../xml/cache.dat') < 86400)
{
$xml = file_get_contents('../../xml/cache.dat');
}
else
{
$xml=..........//此处为程序生成xml段 file_put_contents('../../xml/cache.dat', $xml);}