Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * @author Jota Vicente <jotavrj at gmail dot com>
- *
- */
- class Connection extends PDO { #classe de conexão com o BD
- private $dsn = 'mysql:dbname=testes;host=127.0.0.1';
- private $user = 'root';
- private $password = '';
- public $handle = null;
- function __construct( ) {
- try {
- if ( $this->handle === null ) {
- $dbh = parent::__construct( $this->dsn , $this->user , $this->password );
- $this->handle = $dbh;
- return $this->handle;
- }
- }
- catch ( PDOException $e ) {
- echo 'Connection failed: ' . $e->getMessage( );
- return false;
- }
- }
- function __destruct( ) {
- $this->handle = NULL;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement