PDO大于小于

时间:2015-11-24 18:22:57

标签: php mysql pdo

public function lookForWinner($current_game, $win_cost) {
    $sql = "SELECT * FROM game" . $current_game . " WHERE from <= ? AND to >= ?";
    $query = $this->db->prepare($sql);
    $query->execute(array($win_cost, $win_cost));
    if ($query->rowCount()) {
        $lookForWinner = $query->fetch(PDO::FETCH_ASSOC);
        return $lookForWinner;
    }       
    return false;
}


$lookforwinner = $objGame->lookForWinner($current_game, $wincost);

我正在尝试该代码,但总是返回false。我查看了参数:$current_game = "1"$wincost = 0.19276355021

wincost是浮点型。我和实体的类型是mysql中的文本。但我也试过浮动类型,结果是一样的。

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:1)

对保留字使用反引号,这里有2个

 WHERE `from` <= ? AND `to` >= ?

但是真的要改变你的列名,令人讨厌总是不得不逃避它们