Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**********************************************
- ** (c) 2010 by Raw Games. All rights reserved.
- ** Connects to MySQL
- **********************************************/
- class Database
- {
- //TODO: Modify these static values
- public static $DB_SERVER = "localhost";
- public static $DB_USER = "root";
- public static $DB_PASSWORD = "password";
- public static $DB_NAME = "webdb";
- private $connection;
- public $table_pages;
- public $table_general;
- public $table_navigation;
- public function __construct() {
- $this->OpenConnection();
- }
- public function OpenConnection() {
- $this->connection = mysql_connect(self::$DB_SERVER,self::$DB_USER,self::$DB_PASSWORD);
- $this->table_pages = mysql_query("SELECT * FROM pages", $this->connection);
- $this->table_general = mysql_query("SELECT * FROM general", $this->connection);
- $this->table_navigation = mysql_query("SELECT * FROM general", $this->connection);
- if(!$this->connection){
- die("Unable to connect to MySQL!");
- } else {
- $selection = mysql_select_db(self::$DB_NAME, $this->connection);
- if(!$selection) {
- die("Unable to select the table from MySQL.");
- }
- }
- }
- public function CloseConnection() {
- if(isset($this->connection)) {
- mysql_close($this->connection);
- unset($this->connection);
- }
- }
- }
- $db = new Database();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement