Welcome Guest, Not a member yet? Register   Sign In
Get Mysql insert_id in java
#1

Hi all im new to codeignighter and seem to be having ap roblem with retriving the last insert_id.

what im doing

first of all im not using a form

i catch the button id from java and call my controller function like so

Code:
$('#statusupdate').click(function(){  // when user click no move to next profile and save choice to db
var val_post = $("#msgstatus").val();
$.get("http://mydomain/xxxxxx/mycontroller/set_post/"+ val_post,
function(data){
            
      alert('success');
            });
      });

my controller then calls a function in my model like so

Code:
function set_post($message){
   $user_id = $this->flexi_auth->get_user_id();
   $this->load->model('members_model');
   $data['postid'] = $this->members_model->add_status_post($user_id,$message,'0','0');
   return $data;    
}

my model looks like so

Code:
public function add_status_post ($guid,$message,$type=0,$data=0) {
 
  $dt = date('Y-m-d H:i:s');
  $data = array(
     'tmln_user_id' => $guid ,
     'tmln_message' => urldecode($message) ,
     'tmln_type' => $type,
     'tmln_data' => $data,
     'tmln_date_added' => $dt
  );

$this->db->insert('mytable', $data);

return  $this->db->insert_id();  
   }

how can i get this user id in my java script ?
by the way the row does get inserted Smile
thanks
Reply


Messages In This Thread
Get Mysql insert_id in java - by Marcel - 02-19-2015, 06:37 AM
RE: Get Mysql insert_id in java - by Marcel - 02-19-2015, 07:04 AM
RE: Get Mysql insert_id in java - by CroNiX - 02-19-2015, 09:47 AM
RE: Get Mysql insert_id in java - by Narf - 02-19-2015, 10:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB