PHP移动速度非常慢,我怎样才能加快速度呢?

时间:2014-06-03 23:56:56

标签: php mysql

我发现我的脚本花费的时间比我预期的要长得多。他们一遍又一遍地超时。我不认为我的脚本(如下所示)是无穷无尽的。

 // Post Variables from form to script

  $a = 49;  // variables start at w49 and go to w62
  while ($a<=62) {
     $bclass = 'b'.$a; // my naming convention for posted data
     $wclass = 'w'.$a; // my database's naming convention
     if (!empty($_POST[$wclass])) {
         ${$bclass} = $_POST[$wclass];  // post if not empty.
     }
     $a++; // cycle to next
  }

  // Handle certain forms, described by level

  if ($level === '1') {
      $x = 49;
      $query = "UPDATE users SET "; // beginning of query
        while ($x <= 56) {
          $bclass = 'b'.$x;
          $wclass = 'w'.$x;
          $j = 'A';

          if (!empty(${$bclass})) {
            if ($j = 'A') {
              $query = $query."$wclass = '${$bclass}'";
            } else {
              $query = $query.", $wclass = '${$bclass}'";
            }
            $j++;
          } else {}
        }

        $query = $query." WHERE email = '$email' LIMIT 1"; // end of query
        $result = mysqli_query($conn, $query);

    }
  • 我错过了什么吗?
  • 关于如何提高速度的任何想法?
  • 是否有一个特定的部分/练习让我放慢了速度?

1 个答案:

答案 0 :(得分:3)

while ($x <= 56...

$x何时递增?会不会达到56?