Search code snippets, questions, articles... Chrome Extension

Connect to DB using PDO

<?php 

class Dbn {
    private $host = 'localhost';
    private $user = 'root';
    private $pass = '';
    private $dbName = 'DLcleaners';

    protected function connect() {
        $dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->dbName;
        $pdo = new PDO($dsn, $this->user, $this->pass);
        $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
        return $pdo;
    }
}
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

PDO connect 

Search Index Data (The code snippet can also be found with below search text)

PDO connect to DB
Was this helpful?
0 Comments
Join Devsheet Ask a Question