Reputation: 23
I have a database column "days"
. I would like to 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 to my view using Codeigniter Active Record ?
Upvotes: 2
Views: 50
Reputation: 2907
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'));
Upvotes: 1