首页 > 解决方案 > 使用 codeigniter 从 db 中获取单个数据的更快方法

问题描述

嗨,我只想从我的数据库的一个结果中获取一列。所以我这样做

$this->db->select('myclolumn')->where('id',$id);
$query = $this->db->get('mytable');
$temp=$query->row_array();
$finalresult=$temp['mycolumn'];

也许有更简单或更快的方法来做同样的事情?

标签: phpcodeigniter

解决方案


所以基于丹麦阿里的评论

$this->db->select('myclolumn')->where('id',$id);
$query = $this->db->get('mytable');
$finalresult=$query->row()->mycloumn;

推荐阅读