Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我能';t使用代码点火器更新数据库_Php_Codeigniter - Fatal编程技术网

Php 我能';t使用代码点火器更新数据库

Php 我能';t使用代码点火器更新数据库,php,codeigniter,Php,Codeigniter,我正在使用控制器从模型中调用更新函数,但当我尝试更新列名时,这是行不通的 ----控制器---- 在更新函数中,您没有设置任何值。As设置方法所需的数组值,如果需要,则应给出。好的做法是在更新之前使用设置,最后更新表。按照以下代码更新用户表 function update($data, $id) { $this->db->set($data); $this->db->where($this->uid, $id); $this->db-&

我正在使用控制器从模型中调用更新函数,但当我尝试更新列名时,这是行不通的

----控制器----


在更新函数中,您没有设置任何值。As设置方法所需的数组值,如果需要,则应给出。好的做法是在更新之前使用设置,最后更新表。按照以下代码更新用户表

function update($data, $id)
{
    $this->db->set($data);
    $this->db->where($this->uid, $id);
    $this->db->update($this->tabel);
}
使用此代码。我希望它能正常工作。

在您的控制器中

$result = $this->user->update($data, $row);
变量数据是数组

因此,在您的模型中:

function update($data=array(), $id){
$this->db->where($this->uid, $id);
$this->db->update($this->tabel, $data);
}

它是否给出任何错误消息?但仍然不工作,我检查了我的表,但在函数更新($data=array(),$id){尝试var_dump($data);die;,显示结果如何?
function update($data, $id)
{
    $this->db->set($data);
    $this->db->where($this->uid, $id);
    $this->db->update($this->tabel);
}
$result = $this->user->update($data, $row);
function update($data=array(), $id){
$this->db->where($this->uid, $id);
$this->db->update($this->tabel, $data);
}