SQL附近有语法错误

SQL syntax error near

我正在使用一个模型来 运行 像这样的查询:

    $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};    
    }

我收到以下错误:

Warning: PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BY PRICE DESC' at line 1 in

我不知道为什么?

只需在 ORDER BYAND buysell=buy 之前添加一个 space,如下所示:

$tickerHigh = $this->model->ticker("price",$market," AND buysell='buy'"," ORDER BY PRICE DESC");