简体   繁体   English

PDO大于小于

[英]PDO greater than less than

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);

I am tryin that code but always return false. 我正在尝试该代码,但始终返回false。 I checked my parameters : $current_game = "1" and $wincost = 0.19276355021 我检查了我的参数: $current_game = "1"$wincost = 0.19276355021

wincost is float type. wincost是浮点型的。 my from and to entities' type are text in mysql. 我的从实体到实体的类型是mysql中的文本。 But i also tried with float type and result is same. 但是我也尝试了浮点类型,结果是一样的。

在此处输入图片说明

在此处输入图片说明

Use backticks for reserved words,you have 2 here 使用反引号保留字,这里有2个

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

But really change your column names,its annoying always having to escape them 但实际上要更改您的列名,但总是不得不转义它们,这很烦人

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM