inv*_*bot 1 php mysql activerecord codeigniter date
嗨,我的桌面结构如下
login_session_id, user_id, created_date, ci_cession_id, user_agent_string
created_date字段是mysql_date_time.
我想从这个表中获取最新的一行(基于该created_date字段).如何使用CI Active记录?
试试这个:
$this->db->select('*');
$this->db->from('** YOUR TABLE HERE **');
$this->db->order_by('created_date', 'desc');
$this->db->limit(1);
$query = $this->db->get();
这应该通过选择表中的所有列(您需要指定),排序最近日期在顶部的所有行,然后将其限制为仅最顶行的最新条目.
| 归档时间: | 
 | 
| 查看次数: | 2551 次 | 
| 最近记录: |