繁体   English   中英

我在模型 php codeigniter 中的选择查询有什么问题?

[英]what's wrong with my select query in model php codeigniter?

这是我的代码:

 function getValue($id)
  {
        $this->db->select('value');
        $this->db->where('id',$id);
        $q = $this->db->get('ref_table');
        $data = array_shift($q->result_array());
        $result = $data['value'];
        return $result;
  }

执行时出现错误数组转换为字符串

错误给你答案数组转换为字符串

尝试这个

在模型中

 public function getValue($id)
  {
        $this->db->select('value');
        $this->db->where('id',$id);
        $q = $this->db->get('ref_table');
        $result = $q->result_array();
        return $result;
  }

在控制器中

$data['value'] = $this->Model_name->getValue($id);
$this->load->view('my_view',$data)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM