1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
class Article
{
private
$_id,
$_titre,
$_contenu,
$_categorie,
$_souscategorie;
public function __construct($id, $titre, $contenu, $categorie, $souscategorie)
{
function setId($id)
{
$this->_id = $id;
}
function setTitre($titre)
{
$this->_titre = $titre;
}
function setContenu($contenu)
{
$this->_contenu = $contenu;
}
function setCategorie($categorie)
{
$this->_categorie = $categorie;
}
function setSousCategorie($souscategorie)
{
$this->_souscategorie = $souscategorie;
}
}
public function getId()
{
return $this->_id;
}
public function getTitre()
{
return $this->_titre;
}
public function getContenu()
{
return $this->_contenu;
}
public function getCategorie()
{
return $this->_categorie;
}
public function getSouscategorie()
{
return $this->_souscategorie;
}
}
$bdd = new PDO('mysql:host=localhost;dbname=pixelsnowis', 'root', '');
$req = $bdd->query("SELECT id, titre, contenu, categorie, sous_categorie FROM articles");
while ($donnees = $req->fetch())
{
$art = new Article($donnees['id'], $donnees['titre'], $donnees['contenu'], $donnees['categorie'], $donnees['sous_categorie']);
echo $art->getTitre();
echo $art->getContenu();
}
echo $donnees; |
Partager