codeigniter错误数据库和数组到字符串转换

时间:2017-02-26 10:50:31

标签: database codeigniter activerecord

遇到PHP错误

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);
}

我不知道我的错误在哪里,请更正谢谢

1 个答案:

答案 0 :(得分:0)

需要更新update_customer()函数而不是选择行。

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