Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ArticleManager {
- private $_db;
- public function __construct($db){
- $this->setDb($db);
- }
- public function setDb(PDO $db){
- $this->_db = $db;
- }
- public function addArticle(Article $article){
- $req = $this->_db->prepare('INSERT INTO articles(titreArticle, textArticle) VALUES (:titreArticle , :textArticle)');
- $req->execute(array(
- 'titreArticle' => $article->getTitre(),
- 'textArticle' => $article->getText(),
- ));
- }
- public function deleteArticle($id){
- $this->_db->exec('DELETE FROM articles WHERE id =' .$perso->getId());
- }
- public function getList(){
- $article = [];
- $req = $this->_db->query('SELECT titreArticle FROM articles');
- while ($donnees = $req->fetch(PDO::FETCH_ASSOC))
- {
- $article[] = new Article($donnees);
- }
- return $article;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement