last day (15 days later) » 

15:38
0
A: Get last insert id return null

Rakib RoniYour create function return last insert id. To see your last insert id just use this code in controller function public function lastID() { var_dump($this->photo->create('table_name',$data)); } photo model function function create($tableName, $data) { $this->db->insert($tableName, ...

Return error You must use the "set" method to update an entry.
what do you want to do insert or update ? @zend
First step is insert, next step is to update.
In this process you can insert and return id successfully. @zend
So how can i return that ID in ajax success. Can u show me example ?
15:38
in controller function echo $id=$this->photo->create('table_name',$data); this variable return id
hello
on ajax form submit you can send form data in controller function using this code
$(document).ready(function () {
$("#form_btn_name").on('click', function (e) {
e.preventDefault();
var form_data=$("#form_name");
$.ajax({
type:'POST',
url:'<?php echo base_url()?>controller/function',
data:form_data.serialize(),
success:function(data){
alert(data);
}
});
});
});
then in controller function you receive the post data and after insert using
echo $id=$this->photo->create('table_name',$data);
16:25
just a sec to try it
17:12
its work
thanks

  last day (15 days later) »