Last active
July 16, 2017 01:01
-
-
Save ziedrebhi/4be16ce5aead8f591380 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* A class file to connect to database | |
*/ | |
class DB_CONNECT { | |
var $myconn; | |
/** | |
* Function to connect with database | |
*/ | |
function connect() { | |
// import database connection variables | |
require_once __DIR__ . '/db_config.php'; | |
// Connecting to mysql database | |
$con = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD,DB_DATABASE) or die(mysqli_error($con)); | |
$this->myconn = $con; | |
// returing connection cursor | |
return $this->myconn; | |
} | |
/** | |
* Function to close db connection | |
*/ | |
function close() { | |
// closing db connection | |
mysqli_close($myconn); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment