Reputation:
I am using a model to run a query like so:
$tickerHigh = $this->model->ticker('price',$market,'AND buysell=buy','ORDER BY PRICE DESC');
And here is my model;
$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};
}
I am getting the following error:
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
I'm not sure why?
Upvotes: 1
Views: 302
Reputation: 4578
Just add an space before ORDER BY
and before AND buysell=buy
like this:
$tickerHigh = $this->model->ticker("price",$market," AND buysell='buy'"," ORDER BY PRICE DESC");
Upvotes: 2