php - 使用 codeigniter 从 db 中获取单个数据的更快方法
问题描述
嗨,我只想从我的数据库的一个结果中获取一列。所以我这样做
$this->db->select('myclolumn')->where('id',$id);
$query = $this->db->get('mytable');
$temp=$query->row_array();
$finalresult=$temp['mycolumn'];
也许有更简单或更快的方法来做同样的事情?
解决方案
所以基于丹麦阿里的评论
$this->db->select('myclolumn')->where('id',$id);
$query = $this->db->get('mytable');
$finalresult=$query->row()->mycloumn;
推荐阅读
- magento - Google analytics does not show statistics and looks different
- python - 从 nuke.EvalString_Knob 获取值列表?
- python - Ardupilot - Dronekit 设置车辆的当前位置
- c++ - mingw 编译器和 mvsc 编译库的未定义引用错误
- javascript - Javascript SDK 的开发和登台环境
- sql - 将多于 1 行的输出设置为 1 个变量
- javascript - 我可以在 JavaScript 中更改 CSS 属性的值吗?
- java - 改造 onFailure() 方法的调用次数
- javascript - 检查值是否大于赛普拉斯中的某个数字
- python - 为什么我无法将我的数据系列从 pandas 输入到calmap.yearplot?尝试创建日历热图