2016-10-07 10 views
0

結果セットを返すためにcodeigniterに問題があります。私の選択で1つの列を避けるとき、結果は正しいです。 しかし、私は列(説明)を含める場合、私はエラーが発生し、私の結果セットが壊れています。誰でもこの問題の解決方法を知っています。この列には、&のような文字を含むレコードがあります。 '/ ...これは問題を引き起こすと思うかもしれません。Codeigniter:不正な列に起因する非オブジェクトのメンバー関数result_array()を呼び出しますか?

いくつかの詳細:

'char_set' => 'UTF-8', 
'dbcollat' => 'Latin1_General_100_CS_AS', 

私はすでに成功せず、これらのパラメータを変更しようとしました。

EDITコードの追加:

getおよびget_by関数。コントローラで

public function get($id = NULL, $single = FALSE) { 

    if($id != NULL){ 
     $this->db->where($this->_primary_key, $id); 
     $method = 'row'; 
    } 
    elseif($single == TRUE){ 
     $method = 'row'; 
    } 
    else{ 
     $method = 'result'; 
    } 

    if($_order_by != ''){ 
     if(!count($this->db->ar_orderby)){ 
      $this->db->order_by($this->_order_by); 
     } 

    } 
    //$query = $this->db->query("Select Description from items WHERE Company = 'MINITFR'"); 

    // $array = $query->result_array(); 
    // return 'test'; 
    // var_dump($this->db->get_compiled_select($this->_table_name)); 
    return $this->db->get($this->_table_name)->result_array(); 
    // return $this->db->get($this->_table_name)->$method(); 
} 

public function get_by($where, $single = FALSE) { 
    $this->db->where($where); 
    return $this->get(NULL,$single); 
} 

機能:

public function show_items(){ 

    $this->load->model('item_m'); 
    $this->data['ajax_req'] = TRUE; 
    $where = "Company = '".$this->session->userdata('company')."'"; 
    $this->data['item_list'] = $this->item_m->get_by($where,FALSE); 
    $this->load->view('pages/details/components/item_list', $this->data); 
} 
+1

同様にあなたのコードを追加し –

+1

人々はあなたが追加 –

+0

を支援することは不可能ですcode..otherwiseを追加します。コード。コードなしで人々があなたを助けることはできません –

答えて

0

使用この1:

return $this->db->get('table_name')->result_array(); 
+0

このコードスニペットは問題を解決するかもしれませんが、[説明を含む](http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers)は本当にあなたの投稿の質を向上させるのに役立ちます。将来読者の質問に答えていることを覚えておいてください。そうした人々はあなたのコード提案の理由を知らないかもしれません。 – andreas

+0

上記のコードを追加しましたが、result_array()は機能しません。 –

+0

これは以前と同じエラーを表示していますか? –

関連する問題