Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Connection{
- private $dbhost;
- private $dbname;
- private $dbuser;
- private $dbpass;
- private $conn;
- private $result;
- function __construct(){
- $this->dbhost = 'localhost';
- $this->dbname = '_database';
- $this->dbuser = '_admin';
- $this->dbpass = 'rawrMyGameDevBitches'; //not really
- print( DEBUG ? "" : "Connection object initalised\n<br />\n");
- }
- function connect(){
- $this->conn = mysql_connect($this->dbhost, $this->dbuser, $this->dbpass) or die('Could not connect to MySQL server.');
- print( DEBUG ? "" : "MySQL connection successful\n<br />\n");
- mysql_select_db($this->dbname, $this->conn) or die('Could not select database.');
- print( DEBUG ? "" : "MySQL database ($this->dbname) selected \n<br />\n");
- }
- function runQuery($query){
- if ($query == "") {
- die("You need to provide a query.");
- }
- $this->result = mysql_query($query, $this->conn);
- }
- function getResult(){
- print(DEBUG ? "" : "Results of query: $this->result");
- return $this->result;
- }
- function freeResult(){
- print(DEBUG ? "" : "Freeing result");
- mysql_free_result($this->result);
- }
- function close(){
- mysql_close($this->conn);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement