2017-02-26 59 views
0

一個PHP錯誤遇到笨錯誤datadase和數組到字符串轉換

Severity: Notice 
Message: Array to string conversion 
Filename: database/DB_active_rec.php 
Line Number: 428 

數據庫出錯

Error Number: 1054 
Unknown column 'Array' in 'where clause' 
SELECT * FROM (`user`) WHERE `id` = Array 
Filename: C:\xampp\htdocs\shopping\system\database\DB_driver.php 
Line Number: 331 

我的模型

function update_customer($id) 
    { 
     $this->db->where('id', $id); 
     $query = $this->db->get('user'); 
     return $query; 
    } 

我控制器

function save_order() 
{ 
    $customer = array(
      'name'  => $this->input->post('full_name'), 
      'email'  => $this->input->post('email'), 
      'address' => $this->input->post('address'), 
      'phone'  => $this->input->post('telp') 
      );  
    $this->cart_model->update_customer($customer); 
} 

我不知道我的錯誤在哪裏,請更正,謝謝

+0

您需要使用DB->更新更新時http://www.codeigniter.com/user_guide/database/query_builder.html#updating-data – user4419336

回答

0

需要在update_customer()函數中更新,而不是選擇行。

function update_customer($data = array()) 
    { 
     $this->db->update('user',$data); //updates data in user table 
    } 
+0

感謝全成 – Anonymous