使用codeigniter活动记录获取单个字段输出的值 [英] getting the value of the single field output using the codeigniter active record
本文介绍了使用codeigniter活动记录获取单个字段输出的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下功能应该从数据库中读取给定资产代码的名称。但是会触发错误:试图获取非对象的属性
the following function is supposed to read the name of the given asset code from the database. but it triggers the error: "Trying to get property of non-object"
function sban_name($asset){
$this->db->select('name');
$this->db->from('asset_types');
$this->db->where('code',$asset);
return $this->db->get()->result()->row('name');
}
我要做的就是将资产名称返回给控制器!
All I want is to have the name of the asset returned back to the controller! Your help is highly appreciated!
推荐答案
使用 row()
就像,
return $this->db->get()->row()->name;
这篇关于使用codeigniter活动记录获取单个字段输出的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文