开发者

rails 3 - SQL pass variable to "order"

Im trying to pass variable to the order...

[code].order(['SUM((prices.price * ?) + profiles.shippingCost)', params[:prod_id]]).all

But it doesn't convert the variable to sql instead it gives me.(the variable in this case was "开发者_运维技巧1").

GROUP BY price ORDER BY SUM((prices.price * ?) + profiles.shippingCost), 1):

Is this even possible to do?


You could do:

[code].order("SUM((prices.price * #{params[:prod_id].to_i}) + profiles.shippingCost)").all
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜