2

だから、私はこのコードを持っています:

        } else {

            $photograph_moderation = new PhotographModeration($this->photograph_id);
            $photograph_moderation->purgePhotograph();

            //eventually take to an error page
            die('image is not big enough to upload');

        }

この条件が満たされると、purgePhotograph() 関数が適切に呼び出されますが、スクリプトが終了したようには見えません。die がここで呼び出されない理由はありますか? purgePhotograph() には、スクリプトを強制終了するコマンドもありません。

以下は、purge_photograph 関数です。

public function purgePhotograph() {

    $db = Connect::connect();
    $photograph_id = $db->real_escape_string($this->photograph_id);

    $query = "SELECT * from photographs WHERE id='{$this->photograph_id}'";
    $result = $db->query($query);
    $photograph = $result->fetch_assoc();

    if ($photograph['location'])
    unlink($photograph['location']);

    if ($photograph['thumbnail_location'])
    unlink($photograph['thumbnail_location']);

    if ($photograph['watermark_location'])
    unlink($photograph['watermark_location']);

    if ($photograph['xsmall_location'])
    unlink($photograph['xsmall_location']);

    if ($photograph['small_location'])
    unlink($photograph['small_location']);

    if ($photograph['medium_location'])
    unlink($photograph['medium_location']);

    if ($photograph['large_location'])
    unlink($photograph['large_location']);

    if ($photograph['xlarge_location'])
    unlink($photograph['xlarge_location']);

    if ($photograph['xxlarge_location'])
    unlink($photograph['xxlarge_location']);

    if ($photograph['xxxlarge_location'])
    unlink($photograph['xxxlarge_location']);

    $query = "DELETE from photographs WHERE id='{$this->photograph_id}'";
    $result = $db->query($query);

    $query = "DELETE from photograph_tags WHERE photograph_id='{$this->photograph_id}'";
    $result = $db->query($query);

}
4

4 に答える 4

2

purgePhotograph()が戻るかどうかを確認します。多分それはデッドループを持っているか、本当に長い時間がかかります。

于 2010-05-21T19:59:22.420 に答える
1

たぶん今がphpデバッガモジュールをインストールして問題のコードに足を踏み入れる時です。
フロントエンドとしてのxdebugnetbeansなどは十分に機能します。

于 2010-05-21T20:01:43.417 に答える
1

問題は、purgePhotograph() が 1 を返さないことでした。最後に。次の行を実行するためにこれが必要であることを知りませんでした。

于 2010-05-21T20:03:05.987 に答える
0

それをtry/catchブロックに入れてみてください。おそらく、dieが実行される前に何かが例外をスローしています。

エラーが発生していますか?

于 2010-05-21T20:02:20.560 に答える