public static function getCommentaireByArticleID(&$dataError, $idArticle) { $comm = Commentaire::getDefaultCommentaire(); $collectionComm = array(); if (isset($idArticle)) { try { $statement = DataBaseManager::getInstance()->prepareAndExecuteQuery('SELECT * ' . 'FROM commentaire ' . 'WHERE IdArticle = ?', array($idArticle)); } catch (Exception $ex) { echo "Impossible d'accéder aux données."; $dataError['requete'] = "Impossible d'accéder aux données."; } if ($statement !== false) { foreach ($statement as $row) { $comm = CommentaireFabrique::getCommentaire($dataError, $row['Auteur'], $row['DateParution'], $row['Contenu'], $row['IdArticle'], $row['Id']); $collectionComm[] = $comm; } } else { $dataError['persistance-get'] = "Article Introuvable."; } } else { $dataError['persistance-get'] = "Impossible d'accéder aux données."; } DataBaseManager::destroyQueryResults($statement); return $collectionComm; }
public static function getModelCommentairePut($idCom, $idArticle, $login, $texte) { $model = new self(array()); $commentaire = CommentaireFabrique::getCommentaire($model->dataError, $idCom, $idArticle, $login, $texte); $model->commentaire = CommentaireGateway::putCommentaire($model->dataError, $commentaire); $model->title = "Le commentaire à été inséré"; return $model; }
public static function getModelCommentairePut($Auteur, $dateParution, $Contenu, $IdArticle) { $model = new ModelCommentaire(); $commentaire = CommentaireFabrique::getCommentaire($model->error, $Auteur, $dateParution, $Contenu, $IdArticle); if (!empty($model->getError())) { $model->setData($commentaire); return $model; } $model->setData(CommentaireGateway::putCommentaire($model->error, $commentaire)); return $model; }
public static function getCommentaireAll(&$dataError) { try { $statement = DataBaseManager::getInstance()->prepareAndExecuteQuery('SELECT * FROM Commentaire', array()); } catch (Exception $e) { $dataError['persistance-get'] = "Impossible d'accéder aux données."; } $collectionCommentaire = array(); if ($statement !== false) { foreach ($statement as $row) { $commentaire = CommentaireFabrique::getCommentaire($dataError, $row['id'], $row['idArticle'], $row['Login'], $row['Texte']); $collectionCommentaire[] = $commentaire; } } else { $dataError['persistance-get'] = "Aucun commentaire trouvable."; } DataBaseManager::destroyQueryResults($statement); return $collectionCommentaire; }