Php 代码点火器,插入ID
我正在使用CodeIgniter,我必须在我的表中插入一个ID,但它不起作用,我做了以下操作:Php 代码点火器,插入ID,php,mysql,database,codeigniter,insert,Php,Mysql,Database,Codeigniter,Insert,我正在使用CodeIgniter,我必须在我的表中插入一个ID,但它不起作用,我做了以下操作: $this->db->insert('mytable', $data); $id = $this->db->insert_id(); 这对我来说很正常: function insert($data){ $this->db->insert('users',$data); return $this->db->insert
$this->db->insert('mytable', $data);
$id = $this->db->insert_id();
这对我来说很正常:
function insert($data){
$this->db->insert('users',$data);
return $this->db->insert_id();
}
您必须将ID
字段设置为AUTO INCREMENT
,并确保$data是一个关联数组,如:
$data = array(
'db_field'=>'value'
);
它是固定的,我只是忘了在我的ID列中使用自动增量。谢谢;) 是否已将表配置为具有自动递增的主键?是否可以更新问题以包含$data的值。