Created
September 30, 2016 17:24
-
-
Save devmeireles/edae60d9c93acf0e22ec43b8c8e29955 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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