Thursday, 15 March 2012

Codeigniter select_max and return other row fields -



Codeigniter select_max and return other row fields -

i'm trying select max bid amount on particular item , homecoming more info row max bid found in.

at moment have

$item_id = $this->input->post('item_id'); $this->db->from('bids'); $this->db->where('item_id', $item_id); $this->db->where('outbid_alert', '1'); $this->db->select_max('bid_amount'); $query = $this->db->get(); homecoming $query->result();

this returns max bid item , that's far have gotten. what's best way rest of fields row? run query or utilize subquery?

thanks!

if want homecoming fields row highest bid_amount, order bid_amount , select first row.

$item_id = $this->input->post('item_id'); $this->db->from('bids'); $this->db->where('item_id', $item_id); $this->db->where('outbid_alert', '1'); $this->db->select('*'); $this->db->order_by('bid_amount', 'desc'); $this->db->limit(1); $query = $this->db->get(); homecoming $query->result();

codeigniter

No comments:

Post a Comment