2013-11-21 35 views
1

我有多个条目对应于单个属性。我需要检索最后插入的特定ID的记录。我想这样的,如何检索codeigniter中的特定属性的最后一项

$this->db->select('*'); 
$this->db->from('tbl_appverification'); 
$this->db->where('app_no',$appno); 
$query = $this->db->get(); 
return $query_result(); 

,但我得到的所有值,其中app_no =“5665”

+0

使用笨$这个 - > DB-> insert_id函数... – vijaykumar

回答

0

$query->result()

,如果你想插入的最后的值,你应该在表列时间戳或按自动递增的ID(desc)排序并选取第一条记录。

例如:

$this->db->order_by('id', 'desc'); 

$this->db->order_by('created', 'desc'); 
0

在date_inserted

数据库中添加列并添加该代码

$this->db->order_by('date_inserted','desc/asc'); 
$this->db->limit(1); 
相关问题