【发布时间】:2010-02-07 03:30:57
【问题描述】:
谜语...在while($row = mysql_fetch_assoc($result) and $runningOK) 循环中,如果使用PHP && 运算符代替and,那么mysql_fetch_assoc 将严重失败,并且在运行时仅返回数字1。
我已经尝试了mysql_fetch_array() 并且我仍然遇到1 的问题。只有当且仅当我将&& 替换为and (如当前的while 语句)时才会返回正确的行。
我在之前、内部和之后放置了调试语句以确保这一点。我想知道这是 PHP 的怪癖还是我无法解释的原因。
// Query
$selectQuery = "SELECT * FROM jobs_cache LIMIT 20";
// Run the Selection Query.
$result = mysql_query($selectQuery)
or die('Query Failed: '.mysql_error());
// Loop through results.
$runningOK = TRUE;
$resubmitList = array();
while($row = mysql_fetch_assoc($result) and $runningOK)
{
// Resubmit The Job
try
{
$client->addTaskBackground($row['function_name'],$row['job_data']);
$resubmitList[] = (string)$row['job_cache_id'];
}
catch(Exception $e)
{
echo "Error adding task for job id: " . $row['job_cache_id'];
$runningOK = FALSE;
}
}
【问题讨论】: