Skip to content

Instantly share code, notes, and snippets.

@devmeireles
Created September 30, 2016 17:24
Show Gist options
  • Save devmeireles/edae60d9c93acf0e22ec43b8c8e29955 to your computer and use it in GitHub Desktop.
Save devmeireles/edae60d9c93acf0e22ec43b8c8e29955 to your computer and use it in GitHub Desktop.
public function insert(){
if($this->input->post()){
try{
$error = array();
if(!$this->input->post('artist_slug')){
$error[] = "Slug undefined";
}
if(!$this->input->post('album_name')){
$error[] = "Enter the album name";
}
if(!$this->input->post('album_year')){
$error[] = "Enter the album year";
}
if(count($error) > 0){
throw new Exception(join("| ", $error));
}
$data = array(
'artist_slug' => $this->input->post('artist_slug'),
'album_name' => $this->input->post('album_name'),
'album_year' => $this->input->post('album_year')
);
$msg = "Album created";
$return = array(
"success" => true,
"msg" => $msg,
);
}catch(Exception $e){
$return = array(
"success" => false,
"msg" => $e->getMessage()
);
}
exit(json_encode($return));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment