Order By Rand in Codeigniter

#Order By Rand in Codeigniter

function get_random_page()
{
   $this->db->order_by('id', 'RANDOM');
   or
   $this->db->order_by('rand()');
   $this->db->limit(1);
   $query = $this->db->get('pages');
   return $query->result_array();
}

Codeigniter provides the use of 'RANDOM' when you run a query.
Please follow and like us:
0