我正在使用一个模型来运行这样的查询:
$tickerHigh = $this->model->ticker('price',$market,'AND buysell=buy','ORDER BY PRICE DESC');
这是我的模型;
$tickersHigh = $this->db->prepare("SELECT ".$type." FROM trades WHERE market=? " . $buysell . $order . "");
$tickersHigh->execute(array(strtolower($market)));
$tickerHigh = $tickersHigh->fetch();
if($tickerHigh){
return $tickerHigh->{$type};
}
我得到以下错误:
警告:PDOStatement::execute():SQLSTATE[42000]:语法错误或
访问冲突:1064 SQL语法中有错误;请检查
与右边MySQL服务器版本相对应的手册
在中第1行的“按价格说明”附近使用的语法
我不知道为什么?
最佳答案
只需在ORDER BY
之前和AND buysell=buy
之前添加一个空格,如下所示:
$tickerHigh = $this->model->ticker("price",$market," AND buysell='buy'"," ORDER BY PRICE DESC");