Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- abstract class dbConfig
- {
- private $host = false;
- private $name = false;
- private $pass = false;
- function __construct($hostname, $username, $pass)
- {
- $this->host = $host;
- $this->name = $name;
- $this->pass = $pass;
- }
- public function getHost($host)
- {
- return $this->host;
- }
- public function getName($name)
- {
- return $this->name;
- }
- public function getPass($pass)
- {
- return $this->pass;
- }
- function __destruct()
- {
- #destruction!
- }
- }
- abstract class dbConnect
- {
- private $link = false;
- public function __construct($dbConfig)
- {
- }
- public function openConnection()
- {
- return $this->openConnection;
- }
- public function closeConnection()
- {
- return $this->closeConnection;
- }
- public function getLink()
- {
- return $this->link;
- }
- }
- class dbConnectMySQL extends dbConnect
- {
- public $host = false;
- public $name;
- public $pass;
- public $database;
- public $openConnection;
- public $closeConnection;
- public $startQuery;
- public $getResults;
- public function __construct($host, $name, $pass, $database)
- {
- $this->host = $host;
- $this->name = $name;
- $this->pass = $pass;
- $this->database = $database;
- }
- public function openConnection()
- {
- try
- {
- $this->dbConnect = mysql_connect($this->host, $this->name, $this->pass);
- $this->dbConnect = mysql_select_db($this->database);
- }
- catch (Exception $e)
- {
- return $e;
- }
- }
- public function startQuery($query)
- {
- try
- {
- if(empty($this->openConnection))
- {
- $this->openConnection();
- $this->startQuery = mysql_query($query);
- $this->closeConnection();
- return $this->startQuery;
- }
- else
- {
- $this->startQuery = mysql_query($query);
- return $this->startQuery;
- }
- }
- catch (Exception $e)
- {
- return $e;
- }
- }
- public function getResults()
- {
- try
- {
- return mysql_fetch_assoc($result);
- }
- catch (Exception $e)
- {
- return $e;
- }
- }
- public function closeConnection()
- {
- try
- {
- mysql_close();
- }
- catch (Exception $e)
- {
- return $e;
- }
- }
- public function __destruct()
- {
- #destruction
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement