Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class DB_CONNECT {
- // constructor
- function __construct() {
- // connecting to database
- $this->connect();
- }
- // destructor
- function __destruct() {
- // closing db connection
- $this->close();
- }
- function connect() {
- // import database connection variables
- require_once __DIR__ . '/db_config.php';
- // Connecting to mysql database
- $con = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die(mysql_error());
- // Selecing database
- $db = mysql_select_db(DB_DATABASE) or die(mysql_error()) or die(mysql_error());
- // returing connection cursor
- return $con;
- }
- function close() {
- // closing db connection
- mysql_close();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement