这令人百思不得其解,我必须失去了一些东西简单。 我有一个检查,看看是否我已经插入该交易,以防止重复存在的查询。 下面的代码:
function isaDupe($portableDB, $transactArray)
{
$ref = $transactArray["reference"];
$date = $transactArray["qdate"];
$time = $transactArray["time"];
//prints the query so I can run by hand to test
print "SELECT `counter` FROM transactions WHERE (`reference` = '$ref' AND `qdate` = '$date' AND `time` = '$time') ";
if ($dupeSelectStmt = $portableDB->prepare("SELECT `counter` FROM transactions WHERE (`reference` = ? AND `qdate` = ? AND `time` = ?)"))
{
$dupeSelectStmt->bind_param('sss',$ref, $date, $time);
$dupeSelectStmt->bind_result($counter);
$dupeSelectStmt->execute();
while ($dupeSelectStmt->fetch())
{
break;
}
$numRows = $portableDB->affected_rows;
if ($numRows > 0)
return TRUE;
else if ($numRows == -1)
{
print " ERROR: ";
print_r($portableDB->error);
print_r($dupeSelectStmt->error);
return FALSE;
}
else
return FALSE;
}
}
- 如果我跑手通过同一台服务器上工作台的查询,我得到24行返回。
- 这是相同的,如果我准备,设置和手动执行该语句。
-affected_rows返回-1
--same如果我做了声明NUM_ROWS
-there是没有存储在所述声明或库MySQLi对象错误。
- 如果我把打印的取()语句,它打印一行数据的价值
-if我所取出的行存储到一个数组和计数的结果,它的1
-I've试图与单独的每个变量,同样的事情,运行它。
- 其他查询在同一台服务器上(赫克,同样的MySQLi对象)都工作正常。 选择,更新和插入。