Last active
February 14, 2019 04:56
-
-
Save cry/153df936bf4bb917202d 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 | |
class dbWrapper | |
{ | |
private $db; | |
private $details = array( | |
"host" => "localhost" | |
"dbname" => "dbname" | |
"username" => "root", | |
"password" => "root" | |
) | |
public function __construct() | |
{ | |
$this->db = new \PDO('mysql:'. $this->details['host'] .'=localhost;dbname='. $this->details['dbname'], $this->details['username'], $this->details['password']); | |
} | |
public function executeQuery($query, $params = array()) | |
{ | |
$stmt = $this->db->prepare($query); | |
try | |
{ | |
$results = $this->stmt->execute($params); | |
} | |
catch ($e PDOException) | |
{ | |
return false; | |
} | |
return $results; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment