Skip to content

Instantly share code, notes, and snippets.

@cry
Last active February 14, 2019 04:56
Show Gist options
  • Save cry/153df936bf4bb917202d to your computer and use it in GitHub Desktop.
Save cry/153df936bf4bb917202d to your computer and use it in GitHub Desktop.
<?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