Если ваш html содержит более одной формы
$(function() {
$('#themes').on('change', function(e) {
$(this).closest('form')
.trigger('submit')
})
})
Используя mysqli PHP драйвер, Вы не можете получить insert_id после фиксации.
действительное решение - это:
function add_post($post_data){
$this->db->trans_begin();
$this->db->insert('posts',$post_data);
if( $this->db->trans_status() === FALSE )
{
$this->db->trans_rollback();
return( 0 );
}
else
{
$item_id = $this->db->insert_id();
$this->db->trans_commit();
return( $item_id );
}
}
Источник для структуры кода: https://codeigniter.com/user_guide/database/transactions.html#running-transactions-manually