所以,我有这样的代码:
} 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);
}发布于 2010-05-22 04:01:43
也许现在是安装php debugger module并开始编写相关代码的时候了。
xdebug和例如netbeans作为前端工作得足够好。
发布于 2010-05-22 03:59:22
检查purgePhotograph()是否返回。也许它有一个死循环,或者需要很长时间。
发布于 2010-05-22 04:03:06
哇,问题是purgePhotograph()最后从来没有返回值1。我不知道这是执行以下代码行所必需的。
https://stackoverflow.com/questions/2885157
复制相似问题