classes/phing/tasks/ext/pdo/PDOTask.php
protected function getConnection()
    {
        if ($this->url === null) {
            throw new BuildException("Url attribute must be set!", $this->getLocation());
        }

        try {
            $this->log("Connecting to " . $this->getUrl(), Project::MSG_VERBOSE);

            $user = null;
            $pass = null;

            if ($this->userId) {
                $user = $this->getUserId();
            }

            if ($this->password) {
                $pass = $this->getPassword();
            }

            $conn = new PDO($this->getUrl(), $user, $pass);
            $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

            try {
                $conn->setAttribute(PDO::ATTR_AUTOCOMMIT, $this->autocommit);
            } catch (PDOException $pe) {
                $this->log(
                    "Unable to enable auto-commit for this database: " . $pe->getMessage(),
                    Project::MSG_VERBOSE
                );
            }

            return $conn;
        } catch (PDOException $e) {
            throw new BuildException($e->getMessage(), $this->getLocation());
        }
    }
protected function getConnection()
    {
        if ($this->url === null) {
            throw new BuildException("Url attribute must be set!", $this->getLocation());
        }

        try {
            $this->log("Connecting to " . $this->getUrl(), Project::MSG_VERBOSE);

            $user = null;
            $pass = null;

            if ($this->userId) {
                $user = $this->getUserId();
            }

            if ($this->password) {
                $pass = $this->getPassword();
            }

            $conn = new PDO($this->getUrl(), $user, $pass);
            $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

            try {
                $conn->setAttribute(PDO::ATTR_AUTOCOMMIT, $this->autocommit);
            } catch (PDOException $pe) {
                $this->log(
                    "Unable to enable auto-commit for this database: " . $pe->getMessage(),
                    Project::MSG_VERBOSE
                );
            }

            return $conn;
        } catch (PDOException $e) {
            throw new BuildException($e->getMessage(), $this->getLocation());
        }
    }
protected function getConnection ( ) { if ( $ this -> url === null ) { throw new BuildException ( "Url attribute must be set!" , $ this -> getLocation ( ) ) ; } try { $ this -> log ( "Connecting to " . $ this -> getUrl ( ) , Project :: MSG_VERBOSE ) ; $ user = null ; $ pass = null ; if ( $ this -> userId ) { $ user = $ this -> getUserId ( ) ; } if ( $ this -> password ) { $ pass = $ this -> getPassword ( ) ; } $ conn = new PDO ( $ this -> getUrl ( ) , $ user , $ pass ) ; $ conn -> setAttribute ( PDO :: ATTR_ERRMODE , PDO :: ERRMODE_EXCEPTION ) ; try { $ conn -> setAttribute ( PDO :: ATTR_AUTOCOMMIT , $ this -> autocommit ) ; } catch ( PDOException $ pe ) { $ this -> log ( "Unable to enable auto-commit for this database: " . $ pe -> getMessage ( ) , Project :: MSG_VERBOSE ) ; } return $ conn ; } catch ( PDOException $ e ) { throw new BuildException ( $ e -> getMessage ( ) , $ this -> getLocation ( ) ) ; } }
Creates a new Connection as using the driver, url, userid and password specified.
The calling method is responsible for closing the connection.

@return PDO     the newly created connection.
@throws BuildException if the UserId/Password/Url is not set or there is no suitable driver or the driver fails to load.
Creates a new Connection as using the driver url userid and password specified . The calling method is responsible for closing the connection .