PHP CodeIgniter获得最高价格

时间:2012-11-10 16:28:09

标签: php codeigniter

我这里有这个数组

Array
(
    [0] => 1
    [1] => 2
    [2] => 3
)

数字1,2和3表示值的id ....在数据库中我所有这些id都有价格(费用)而且所有费用都不同......我想要做什么获得最高费用并返回一个值......

$ query = $ this-> db-> get_where($ this-> tbl_name,array('id'=> $ id)); $ data = $ query-> row();

我如何调整上面的代码以找到最高费用并返回该行?

谢谢, Ĵ

1 个答案:

答案 0 :(得分:4)

$this->db->get_where($this->tbl_name, array('id' => $id))->order_by("fee", "DESC")->row();