public function ajouterAction() { $dba = Zend_Registry::get('dba'); $this->_helper->layout->disableLayout(true); $this->_helper->viewRenderer->setNoRender(true); $id_genre = $_POST["id_genre"]; $nom_play = $_POST["nom_play"]; $result = array(); if ($id_genre != null && $nom_play != null) { $datas = array('NOM_PLAY' => $nom_play, 'ID_GENRE' => $id_genre); $result["STATUS"] = "OK"; $result["NOM_PLAY"] = $nom_play; $genre_table = new Application_Model_Genre($dba); $genre_row = $genre_table->find($id_genre); $genre = $genre_row->current(); $result["GENRE_NAME"] = $genre->NOM_G; $dba->beginTransaction(); try { $dba->insert('PLAYLIST', $datas); $dba->commit(); } catch (Exception $e) { $dba->rollBack(); echo $e->getMessage(); } $playlist_table = new Application_Model_Playlist($dba); $where = $dba->quoteInto("NOM_PLAY = ?", $nom_play); $playlist = $playlist_table->fetchRow($where, "PLAY_ID DESC"); $result["PLAY_ID"] = $playlist->PLAY_ID; } else { $result["STATUS"] = "FAIL"; } $json = json_encode($result); echo $json; }