我有一个插入查询(活动记录样式)用于将表单字段插入MySQL表.我想获取插入操作的最后一个自动递增的id作为我的查询的返回值,但我有一些问题.
控制器内部:
function add_post(){
$post_data = array(
'id' => '',
'user_id' => '11330',
'content' => $this->input->post('poster_textarea'),
'date_time' => date("Y-m-d H:i:s"),
'status' => '1'
);
return $this->blog_model->add_post($post_data);
}
Run Code Online (Sandbox Code Playgroud)
内部模型:
function add_post($post_data){
$this->db->trans_start();
$this->db->insert('posts',$post_data);
$this->db->trans_complete();
return $this->db->insert_id();
}
Run Code Online (Sandbox Code Playgroud)
我没有得到任何东西作为模型中add_post的返回