Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- *
- */
- /** E-libarry_IT
- *
- * @author Admin
- */
- class Database {
- private $host;
- private $user;
- private $password;
- private $database;
- public $conn;
- function __construct($filename) {
- if(is_file($filename)) include $filename;
- else throw new Exception("Error!");
- $this->host = $host;
- $this->user = $user;
- $this->password = $password;
- $this->database = $database;
- $this->connect();
- }
- private function connect()
- {
- $this->conn = mysql_connect($this->host, $this->user, $this->password)
- //connected to the server .
- if (!$this->conn) {
- throw new Exception("Error: not connected to the server.");
- }
- // select the database .
- if(!mysql_select_db($this->conn,$this->database))
- throw new Exception("Error: No database selected");
- else
- echo 'OK';
- }
- function close(){
- mysqli_close();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement