我有一个数据库列"days"
。我想随机插入一周中的日期Tuesday,Monday,Thursday,Wednesday
| id | Days
-------------------
| 1 | Tuesday
| 2 | Monday
| 3 | Thursday
| 4 | Wednesday
如何使用Codeigniter Active Record返回日期以查看我的视图?
答案 0 :(得分:1)
如果天列只包含星期几,那么您可以这样做:
$this->db->query(SELECT * FROM TABLENAME ORDER BY FIELD(Days, 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY'));