我正在使用模型来运行这样的查询:
$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服务器版本 语法使用附近' BY PRICE DESC'
中的第1行
我不确定为什么?
答案 0 :(得分:2)
只需在ORDER BY
之前和AND buysell=buy
之前添加一个空格,如下所示:
$tickerHigh = $this->model->ticker("price",$market," AND buysell='buy'"," ORDER BY PRICE DESC");