PHP SQLITE LOADING LAG

时间:2013-10-08 14:58:20

标签: php sqlite lag

enter image description here此代码在执行时会导致大量延迟。没有这个位需要0.78秒。代码需要6.87秒。那里有人能指出滞后代码并为我提供消除这种滞后的解决方案。非常感谢您的帮助。

    <?php 
$row=0;
while ($r=$sth->fetch(PDO::FETCH_ASSOC)) {
  $row++;

  foreach($r as $k => $v) { ${$k} = $v; } // get all columns as variables

  //print a table row
  $sql="SELECT items.id i_id, status,manufacturerid,model,label,cpuno,corespercpu from items,item2soft ".
       " where item2soft.itemid=items.id  AND item2soft.softid={$r['id']}";

  $sthi=db_execute($dbh,$sql);
  $ri=$sthi->fetchAll(PDO::FETCH_ASSOC);
  $nitems=count($ri);
  $institems="";
  $licitems=0;

  for ($i=0;$i<$nitems;$i++) {
    $rstatus=(int)$ri[$i]['status'];
    if ($rstatus==1) { $attr="style='background-color:green;font-weight:bold;color:#efefef' title='Status: Stored'"; }
    elseif ($rstatus==2) { $attr="style='background-color:red;font-weight:bold;' title='Status: Defective'"; }
    elseif ($rstatus==3) { $attr="style='background-color:#cecece;font-weight:bold;' title='Status: Obsolete'"; }
    else { $attr=" title='Status: In Use' "; }

    $x=($i+1).": <span $attr >({$ri[$i]['label']}) </span>".$agents2[$ri[$i]['manufacturerid']]['title']." ".$ri[$i]['model'];

    if ($i%2) $bcolor="#D9E3F6";
    //if ($i%2) $bcolor="#ECF1FB";
    else $bcolor="#ffffff";
    $institems.="<div style='margin:0;padding:0;background-color:$bcolor'>".
                "<a href='$scriptname?action=edititem&amp;id={$ri[$i]['i_id']}'>$x</a></div>";

    if (empty($lictype) || $lictype==0) { $licitems++; } //per box
    elseif ($lictype==1) { $licitems+=$ri[$i]['cpuno']; } //per cpu
    elseif ($lictype==2) { $licitems+=$ri[$i]['cpuno']*$ri[$i]['corespercpu']; } //per core
  }

由于

0 个答案:

没有答案