How to get random records in MySQL using CodeIgniter?

Member

bailey_conroy

by bailey_conroy , in category: Technology , a month ago

How to get random records in MySQL using CodeIgniter?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by trycia.jones , a month ago

order_by function is used to order the records from a table in CodeIgniter.

1
2
3
4
5
// Getting random rows from database in CodeIgniter
$this->db->select('*');
$this->db->from('table_name');
$this->db->order_by("column_name", "random");
$result = $this->db->get()->result();