Welcome Guest, Not a member yet? Register   Sign In
Order column desc in one query $data
#1

Hi ,maybe this just simple question, but i don't have answer yet 

My query is this :
$data['employee'] = $this->m_data->get_data('employee')->result();

I want to order descending, i try this 
$data['employee'] = $this->m_data->get_data('employee')->order_by("employee_id desc")->result();
But it gave error like this :


Message: Call to undefined method CI_DB_mysqli_result::order_by()

How to fix the query ?
Reply
#2

(This post was last modified: 02-20-2020, 02:13 AM by muuucho.)

(02-20-2020, 02:02 AM)kelapamuda Wrote: Hi ,maybe this just simple question, but i don't have answer yet 

My query is this :
$data['employee'] = $this->m_data->get_data('employee')->result();

I want to order descending, i try this 
$data['employee'] = $this->m_data->get_data('employee')->order_by("employee_id desc")->result();
But it gave error like this :


Message: Call to undefined method CI_DB_mysqli_result::order_by()

How to fix the query ?
Every method returns allows for chaning, except get and get_where which returns the result. Try to place order_by() before get_data()
Reply
#3

Show the code for m_data->get_data()
Reply
#4

Finally it works,i just changet the query sentence
$data['tbl_tamu'] = $this->db->query("SELECT * FROM tbl_tamu order by tbl_tamu_id desc")->result();
Reply




Theme © iAndrew 2016 - Forum software by © MyBB