Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##fichier forum.class.php##
- <?php
- class Forum{
- private $db;
- private $results;
- function __construct() {
- $db = new DBConnect();
- }
- function show_topics() {
- $results = $this->results;
- $results = $this->db->query('SELECT * FROM forum_topics');
- $results = $results->fetch();
- return $results;
- }
- function show_replies($id) {
- }
- }
- ?>
- ##fichier dbconnect.class.php##
- <?php
- class DBconnect extends PDO {
- private $db_user = 'root';
- private $db_pass = '';
- private $db_name = 'mysql:host=127.0.0.1;dbname=blog';
- function __construct() {
- parent::__construct($this->db_name, $this->db_user, $this->db_pass);
- parent::setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
- }
- }
- ?>
- ##fichier index.php##
- <?php
- require("core.php");
- loadclass('dbconnect');
- loadclass('forum');
- $res = new Forum();
- $results = $res->show_topics();
- print_r($results);
- foreach($results as $a => $b) {
- echo "<pre>";
- echo "$a => $b";
- echo "</pre>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement