Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TWO CLASSES
- class USER
- {
- private $db;
- function __construct($DB_con)
- {
- $this->db = $DB_con;
- }
- class FORUM {
- function __construct($DB_con)
- {
- $this->db = $DB_con;
- }
- public function getSubject() {
- $table = "";
- try {
- $query = $this->db->prepare("DESCRIBE posts");
- $query->execute();
- $forumrow = $query->fetchall(PDO::FETCH_COLUMN);
- print_r($forumrow);
- } catch(PDOException $e) {
- echo $e->getMessage();
- }
- }
- }
- $forum = new FORUM($DB_con);
- $forum->getSubject();
- I have a database conntection too.
- session_start();
- $DB_host = "localhost";
- $DB_user = "root";
- $DB_pass = "";
- $DB_name = "dblogin";
- try
- {
- $DB_con = new PDO("mysql:host={$DB_host};dbname={$DB_name}",$DB_user,$DB_pass);
- $DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }
- catch(PDOException $e)
- {
- echo $e->getMessage();
- }
- include_once 'users.php';
- $user = new USER($DB_con);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement