1

PHPExcelを使用してExcelからMySQLデータベースにデータをアップロードしようとしています。私のコードはlocalhostで正常に動作していますが、サーバーではデータをExcelからデータベースに更新していますが、コントロールはループから出ていません(プロセスを終了していません)。3000行のExcelファイルでは同じコードが正常に機能しますが、40000行では機能しません。私を助けてください

foreach($sheetData as $str)
    {

        if($z == $chunk_s)
        {
            break;
        }
        $z++;
        if($i == 1)
        {
            $i++;
            $val1 = $str['A'];
            $val2 = $str['B'];
            $val3 = $str['C'];
            $val4 = $str['D'];
            $val5 = $str['E'];
            $val6 = $str['F'];
            $val7 = $str['G'];
            $val8 = $str['H'];
            $val9 = $str['I'];
            $val10 = $str['J'];
            //$val11 = $str['K'];
            $val12 = $str['K'];
            $val13 = $str['L'];
            $val14 = $str['M'];
            $val15 = $str['N'];
            $val16 = $str['O'];
            $val17 = $str['P'];
            $val18 = $str['Q'];
            $val19 = $str['R'];
            $val20 = $str['S'];
            $val21 = $str['T'];

            if($val1 == "Order Date" && $val2 == "No" && $val3 == "Customer No." && $val4 == "Bill-to Name" && $val5 == "Bill-to Contact" && $val6 == "Phone No." && $val7 == "Bill-to City" && $val8 == "E-Mail" && $val9 == "Item No." && $val10 == "Description" && $val12 == "Maximum Agreed Repair Amount" && $val13 == "Status" && $val14 == "Your Reference" && $val15 == "Fault Code" && $val16 == "Resolution Code" && $val17 == "CHAWAGO Code" && $val18 == "Expected Finishing Date" && $val19 == "Amount Including VAT" && $val20 == "Posted Invoice No." && $val21 == "AirWay Bill No.")
            {
            }
            else
            {
                echo "Invalid Excel File.";
                break;
            }
        }
        else
        {       
            $i++;   
            $val1 = $str['A'];
            $val2 = $str['B'];
            $val3 = $str['C'];
            $val4 = $str['D'];
            $val5 = $str['E'];
            $val6 = $str['F'];
            $val7 = $str['G'];
            $val8 = $str['H'];
            $val9 = $str['I'];
            $val10 = $str['J'];
            $val11 = "";
            $val12 = $str['K'];
            $val13 = $str['L'];
            $val14 = $str['M'];
            $val15 = $str['N'];
            $val16 = $str['O'];
            $val17 = $str['P'];
            $val18 = $str['Q'];
            $val19 = $str['R'];
            $val20 = $str['S'];
            $val21 = $str['T'];

            if($val1 == "END OF THE RECORD")
            {
                echo "End of the record is reached!<br /><br />";

                echo "<br />Number of New Records Added : " . $j . "<br />";
                echo "<br />Number of Updated Records  : " . $l . "<br />";
                echo "<br /><a href=''>Click here to go home.</a></pre>";
                exit;

                //break;
            }

            if($val1 == "" && $val2 == "" && $val3 == "" && $val4 == "" && $val5 == "" && $val6 == "" && $val7 == "" && $val8 == "" && $val9 == "" && $val10 == "" && $val12 == "" && $val13 == "" && $val14 == "" && $val15 == "" && $val16 == "" && $val17 == "" && $val18 == "" && $val19 == "" && $val20 == "" && $val21 == "")
            {
                echo "Blank row occurred. Please remove all the blank rows and start uploding the file.<br /><br />";
                echo "<br />Number of New Records Added : " . $j . "<br />";
                echo "<br />Number of Updated Records  : " . $l . "<br />";
                echo "<br /><a href=''>Click here to go home.</a></pre>";
                exit;
            }
            else
            {
                $res1 = mysql_query("select * from servicedetails where Number = '$val2' and Customer_No = '$val3'");
                $num = mysql_num_rows($res1);
                if($num == 0)
                {                
                    $res = mysql_query("INSERT INTO servicedetails (Order_Date, Number, Customer_No, Bill_to_Name, Bill_to_Contact, Phone_No, Bill_to_City, EMail, Item_No, Description, Repair_Status_Code, Maximum_Agreed_Repair_Amount, Status, Your_Reference, Fault_Code, Resolution_Code, CHAWAGO_Code, Expected_Finishing_Date, Amount_Including_VAT, Posted_Invoice_No, AirWay_Bill_No) VALUES ('$val1', '$val2', '$val3', '$val4', '$val5', '$val6', '$val7', '$val8', '$val9', '$val10', '$val11', '$val12', '$val13', '$val14', '$val15', '$val16', '$val17', '$val18', '$val19', '$val20', '$val21')");         
                    $j++;
                    if($j > $chunk_s)
                    {
                        echo "<br />Number of New Records Added : " . $j . "<br />";
                        echo "<br />Number of Updated Records  : " . $l . "<br />";
                        echo "<br /><a href=''>Click here to go home.</a></pre>";
                        exit;
                    }
                }
                else
                {
                    $res = mysql_query("update servicedetails set Status = '$val13' where Number = '$val2' and Customer_No = '$val3'");
                    $l++;
                    if($l > $chunk_s)
                    {
                        echo "<br />Number of New Records Added : " . $j . "<br />";
                        echo "<br />Number of Updated Records  : " . $l . "<br />";
                        echo "<br /><a href=''>Click here to go home.</a></pre>";
                        exit;
                    }
                }
            }
        }
    }
4

1 に答える 1

0

言いにくい。

  • おそらくデータが多すぎますか?
  • スクリプトがphpメモリを超えていますか?
  • 呼び出しが多すぎるためにMySQLが終了しますか?
  • 行に値があります$val1 == "END OF THE RECORDか?
  • とはどういう意味$sheetdata.size();ですか?

あなたが言った

コントロールがループから出ていない(プロセスを終了していない)

コントロールとはどういう意味ですか?

于 2013-03-29T11:30:43.310 に答える