我在while循环中有这个函数,由于某种原因它说所有记录都是重复的。
我试过了:
$tst->RecordCount() === 1
$tst->RecordCount() == 1
$tst->RecordCount() = 1
$tst->RecordCount() === '1'
$tst->RecordCount() == '1'
$tst->RecordCount() = '1'
$tst->RecordCount() === "1"
$tst->RecordCount() == "1"
$tst->RecordCount() = "1"
但似乎没有工作
$sql45 = "SELECT
count(*)
FROM
companies
WHERE
MC = " . $test;
$tst = $conn->Execute($sql45);
if ($tst === false) die("horrible death:" . $conn->ErrorMsg() . " SQL: " . $sql45);
if($tst->RecordCount() === 1){
echo $test . "<br>";
echo "Duplicate record <br>";
continue;
}
这是我收到的
545481
Duplicate record
45
Duplicate record
11111
答案 0 :(得分:0)
你的记录数总是1.你有
SELECT count(*) FROM companies WHERE MC = somevalue
这总是返回一行,即记录计数为1.也许它是你想要得到的计数的值?
答案 1 :(得分:-1)
您可以使用以下方法检查是否存在行:
SELECT EXISTS(SELECT 1 FROM table1 WHERE ...)
它比计数(*)更有效。希望它有所帮助。