public function connectPDO($selectDb = true)
    {
        if (null !== self::$_linkId) {
            return true;
        }
        try {
            self::$_linkId = new PDO(
                'mysql:host=' . $this->_server,
                $this->_user,
                $this->_pass,
                array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'')
            );
            self::$_linkId->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            if ($selectDb) {
                self::$_linkId->query('USE ' . $this->_database);
            }
        } catch (PDOException $e) {
            $this->_error = $e->getMessage();
            return false;
        }
        return true;
    }
public function connectPDO($selectDb = true)
    {
        if (null !== self::$_linkId) {
            return true;
        }
        try {
            self::$_linkId = new PDO(
                'mysql:host=' . $this->_server,
                $this->_user,
                $this->_pass,
                array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'')
            );
            self::$_linkId->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            if ($selectDb) {
                self::$_linkId->query('USE ' . $this->_database);
            }
        } catch (PDOException $e) {
            $this->_error = $e->getMessage();
            return false;
        }
        return true;
    }
public function connectPDO ( $ selectDb = true ) { if ( null !== self :: $ _linkId ) { return true ; } try { self :: $ _linkId = new PDO ( 'mysql:host=' . $ this -> _server , $ this -> _user , $ this -> _pass , array ( PDO :: MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'' ) ) ; self :: $ _linkId -> setAttribute ( PDO :: ATTR_ERRMODE , PDO :: ERRMODE_EXCEPTION ) ; if ( $ selectDb ) { self :: $ _linkId -> query ( 'USE ' . $ this -> _database ) ; } } catch ( PDOException $ e ) { $ this -> _error = $ e -> getMessage ( ) ; return false ; } return true ; }
Connect to a Database host and select database using variable initialized above
@access public
@param bool $selectDb
@return bool If Database connection successful return true else return false
Connect to a Database host and select database using variable initialized above