I have a database column "days"
. After insert the days of the week randomly (example Tuesday,Monday,Thursday,Wednesday
):
| id | Days
-------------------
| 1 | Tuesday
| 2 | Monday
| 3 | Thursday
| 4 | Wednesday
How would I return the days in order using CodeIgniter active record?
If the column Days only contains the day of week, then you could do this:
$this->db->query(SELECT * FROM TABLENAME ORDER BY FIELD(Days, 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY'));