Skip to content

Instantly share code, notes, and snippets.

@eboominathan
Created October 12, 2018 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eboominathan/8c085fc11da94658aa9141df0942d382 to your computer and use it in GitHub Desktop.
Save eboominathan/8c085fc11da94658aa9141df0942d382 to your computer and use it in GitHub Desktop.
Sample API
/* API */
Public function get_id(){
$result = array();
/* Check data already Present or not */
$check_data = $this->db->order_by('id','desc')->get('student_list')->row_array();
if(!empty($check_data)){ /* Already have data */
$student_id = $check_data['student_id'];
$student_id++;
}else{ /* Empty data */
$student_id = 'S00001';
}
$datas['name'] = $_POST['name'];
$datas['student_id'] = $student_id;
//$response = $this->db->insert('table',$datas);
$response = true;
if($response){
$data = array('status' => true,'message'=>'Inserted successfully');
}else{
$data = array('status' => false,'message'=>'Insertion failed');
}
echo json_encode($data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment