public function action_add_band() { $user = $this->is_logged(); if ($user === false) { return Redirect::to_action('login'); } else { $band = new Band(null); if ($_POST['name'] != "") { $band->set_name_band($_POST['name']); } else { $this->_error_msg = "Il y a une erreur dans le nom du groupe. <br> "; $this->_error_form = true; } if (is_numeric($_POST['anneeF']) and preg_match("/^[0-2][0-9]{3}+\$/", $_POST['anneeF']) == 1) { $band->set_date_form_band($_POST['anneeF']); } else { $this->_error_msg .= "Il y a une erreur dans la date de formation (Format : AAAA).<br> "; $this->_error_form = true; } if (is_numeric($_POST['anneeD']) or $_POST['anneeD'] == "") { $band->set_date_disband_band($_POST['anneeD']); } if ($this->_error_form == false) { $band->set_id_user_lif($user->get_id_user_lif()); $band->add(); return Redirect::to_action('band'); } else { return Redirect::to_action('band@add')->with('error', true)->with('form', $_POST)->with('error_msg', $this->_error_msg); } } }
public function for_song() { $error = array(); $song_clem = DB::connection('clem')->query('SELECT title, album, artist, albumartist, year, genre, filename,track FROM songs'); foreach ($song_clem as $value) { /* AJOUT D'ARTISTES */ if (trim($value->artist) != '') { $band = new Band(null, 1, utf8_encode($value->artist), null, null); try { $band->add(); } catch (Exception $e) { $this->_error_msg .= 'artiste :' . $e->getMessage() . '<br>'; break; } } /* AJOUT D'ALBUM */ if (trim($value->album) != '') { $name_band = Band::from_name_band(utf8_encode($value->artist)); $album = new Album(null, $name_band[0]->id_band, 1, utf8_encode($value->album), $value->year); try { $album->add(); } catch (Exception $e) { $this->_error_msg .= 'album: ' . $e->getMessage() . '<br>'; break; } } if (trim($value->title) != '') { $album = Album::from_name_album(utf8_encode($value->album)); $song = new song(null, 1, utf8_encode($value->title), $value->year, null, $value->filename, $value->track); $song->set_id_kind(explode(';', $value->genre)); $song->id_album = $album[0]->id_album; try { $song->add(); } catch (Exception $e) { $this->_error_msg .= 'chanson: ' . $e->getMessage() . '<br>'; break; } } } // var_dump($song_clem); }