Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class BddClass {
- public $bdd = null;
- public function __construct() {
- $hostname = "localhost";
- $dbname = "common-database";
- $username = "root";
- $password = "password";
- try {
- $this->bdd = new PDO("mysql:host=$hostname;dbname=$dbname", $username, $password);
- $this->bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- } catch (PDOException $e) {
- $this->bdd = null;
- die($e->getMessage());
- }
- }
- public function get_error() {
- $this->bdd->errorInfo();
- }
- public function __destruct() {
- $this->bdd = null;
- }
- public static function getConnection() {
- return new BddClass();
- }
- public function lastInsertId(){
- return $this->bdd->lastInsertId();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement