您好,我想比较两列中的两个值,但它无法正常工作。我需要转换结果吗?我做错了什么?
$query = "SELECT `columm1`, `columm2` FROM `table` WHERE `id` = ? ";
$stmt = $conn->prepare($query);
$stmt->bindParam(1,$eventID);
$stmt->execute();
$currentJoin = (int) $stmt->fetchColumn();
$maxParticipants = (int) $stmt->fetchColumn(1);
if($currentJoin >= $maxParticipants){
return;
}
else{
最佳答案
Warning There is no way to return another column from the same row if you use PDOStatement::fetchColumn() to retrieve data. -
fetchColumn()
您可以使用fetch()
相反
$stmt->execute();
$result = $stmt->fetch();
if($result[0] >= $result[1] ){
// ...
}
关于php - 获取特定列并比较值 php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56500744/