Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Database
- {
- //Username for the database.
- private $username = "";
- //Password for the database.
- private $password = "";
- //Remote address of the database or localhost if local.
- private $addr = "";
- //The connection link.(if not connect() is null by default).
- private $connection = null;
- function __construct($username,$password,$addr)
- {
- $this->username = $username;
- $this->password = $password;
- $this->addr = $addr;
- }
- //Establishes a connection to the database.
- function connect()
- {
- if($this->connection != null)
- {
- $con = mysql_connect($this->addr,$this->username,$this->password);
- if($con == false)
- {
- return false;
- }
- else
- {
- $this->connection = $con;
- return $con;
- }
- }
- else
- {
- return false;
- }
- }
- //Getters.
- function getUsername()
- {
- return $this->username;
- }
- function getPassword()
- {
- return $this->password;
- }
- function getAddr()
- {
- return $this->addr;
- }
- function getConnection()
- {
- return $this->connection;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement