Last active
August 17, 2020 18:25
-
-
Save chrisoverstreet/5d59fe7833fe65454005e3cee613dd8f 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
class DbHandler | |
{ | |
private $conn; | |
private $pdo; | |
/** | |
* DbHandler constructor. | |
* Pass in connections to prevent race conditions being cause by multiple connections being created | |
* @param {mysqli} $dbConnection - optional mysqli connection | |
* @param {PDO} $pdoConnection - optional pdo connection | |
*/ | |
function __construct($dbConnection = null, $pdoConnection = null) | |
{ | |
/** | |
* @var DbConnect | |
*/ | |
$db = new DbConnect(); | |
/** | |
* @var mysqli | |
*/ | |
$this->conn = $dbConnection ? $dbConnection : $db->connect(); | |
/** | |
* @var PDO | |
*/ | |
$this->pdo = $pdoConnection ? $pdoConnection : $db->getPdoConnection(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment