I don't know why but the insert query fail, this is my code:
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();
}
}
Now the $resource
contains all data like:
auto_increment
so I doesn't include the id in the $data
variable. In the network tab I get: Can't insert the resource
id: null
status: "SUCCESS"
why happean this?
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");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.