簡體   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