使用 codeigniter 活动记录获取单个字段输出的值 [英] getting the value of the single field output using the codeigniter active record

查看:25
本文介绍了使用 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!

推荐答案

Use row() like,

return $this->db->get()->row()->name;

这篇关于使用 codeigniter 活动记录获取单个字段输出的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆