Skip to content

Instantly share code, notes, and snippets.

Created October 22, 2015 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1392df456339de836456 to your computer and use it in GitHub Desktop.
Save anonymous/1392df456339de836456 to your computer and use it in GitHub Desktop.
public function __construct(){
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "dbname";
$this->dbh = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$this->dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
public function one(){
$sth = $this->dbh->prepare('select * from ...');
}
@J7mbo
Copy link

J7mbo commented Oct 22, 2015

public function __construct(\PDO $pdo) {
$this->db = $pdo;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment