在CodeIgniter中插入查询失败


Insert query fail in CodeIgniter

我不知道为什么,但插入查询失败了,这是我的代码:

public function insert_resource($resource) 
{
    try
    {
        $data = array(
            'descrizione' => $resource['descrizione'],
            'sigla' => $resource['sigla'],
            'colore' => $resource['colore'],
            'planning' => $resource['planning'],
            'data' => 0
        );
        if(!$this->db->insert('risorse', $data))
        {
            throw new Exception("Can't insert the resource");
        }
    }
    catch(Exception $e)
    {
        echo $e->getMessage();
    }
}

现在$resource包含所有数据,如:

  • 描述
  • sigla
  • 彩色
  • 计划
  • 数据
    除了id,它是auto_increment,所以我不在$data变量中包含id。在"网络"选项卡中,我得到:

无法插入资源

id:空

状态:";成功";

为什么会这样?

LAST_QUERY

INSERT INTO `risorse` (`descrizione`, `sigla`, `colore`, `planning`, `data`, `id`) VALUES ('sdfdf', 'fdfd', '12FFEF', 'NoviSoft', 0, 'null')
$this->db->insert('risorse', $data);
if ( $this->db->affected_rows() == 0 ){ 
     echo $this->db->_error_message();
     throw new Exception("Can't insert the resource");
}