getting the value of the single field output using the codeigniter active record

后端 未结 4 717
你的背包
你的背包 2020-12-16 11:46

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\"

         


        
4条回答
  •  伪装坚强ぢ
    2020-12-16 12:32

    do like this, asset_types is your table name

    function sban_name($asset){
        $this->db->select('name');
        $this->db->from('asset_types');
        $this->db->where('code',$asset);
        return $this->db->get('asset_types');
    }
    

    And in your controller acess it like

    $result=$this->modelname->sban_name('$asset')->row();
    $name=$result->name;
    

提交回复
热议问题