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() 函数,但脚本似乎永远不会死掉。有没有理由不在这里调用死?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 调试器模块并进入相关代码的时候了。
xdebug和例如netbeans作为前端工作得很好。

于 2010-05-21T20:01:43.417 回答
1

Wow, the problem was purgePhotograph() never had a return 1; at the end. I didn't know this was required for following lines to execute.

于 2010-05-21T20:03:05.987 回答
0

尝试将其放入 try/catch 块中。也许在 die 可以被执行之前有什么东西抛出了异常。

你有什么错误吗?

于 2010-05-21T20:02:20.560 回答