dongmeng9048 2015-11-24 18:22
浏览 113
已采纳

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

I am tryin that code but always return false. I checked my parameters : $current_game = "1" and $wincost = 0.19276355021

wincost is float type. my from and to entities' type are text in mysql. But i also tried with float type and result is same.

enter image description here

enter image description here

  • 写回答

1条回答 默认 最新

  • duancai7002 2015-11-24 18:37
    关注

    Use backticks for reserved words,you have 2 here

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

    But really change your column names,its annoying always having to escape them

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请教如何关于Msg文件解析
  • ¥200 sqlite3数据库设置用户名和密码
  • ¥15 AutoDL无法使用docker install吗?
  • ¥15 cups交叉编译后移植到tina sdk的t113,只需要实现usb驱动打印机,打印pdf文件
  • ¥30 关于#wireshark#的问题:需要网络应用流量数据集需要做长度序列的实验,需要与应用产生的会话的数据包的长度,如视频类或者聊天类软件
  • ¥15 根据上述描述表示泥浆密度沿着管路的长度方向在不断变化,如何来表示泥浆密度随管路的变化(标签-matlab|关键词-流计算)
  • ¥21 matlab可以把图像数据转换为小波分析吗
  • ¥60 基于香农编码的图像压缩算法实现
  • ¥15 matlabGUI绘制一个函数与其导数的图像
  • ¥20 大数据采集用Python爬取猫眼电影数据