src/SC.php
public function connect($type, $host, $dbname = '', $username = null, $password = null, array $options = array())
    {
        if ($this->PDO) {
            // If this object already has a PDO object, don't attempt a new connection
            return $this;
        }

        $dsn = '';

        if ($type == 'sqlite') {
            $dsn = "{$type}:{$host}";
        } else {
            $dsn = "{$type}:host={$host};dbname={$dbname}";
        }
        $PDO = new PDO($dsn, $username, $password, $options);

        if (!$PDO) {
            return false;
        }

        $this->PDO = $PDO;

        $this->setEscapeChar();
        return $this;
    }
public function connect($type, $host, $dbname = '', $username = null, $password = null, array $options = array())
    {
        if ($this->PDO) {
            // If this object already has a PDO object, don't attempt a new connection
            return $this;
        }

        $dsn = '';

        if ($type == 'sqlite') {
            $dsn = "{$type}:{$host}";
        } else {
            $dsn = "{$type}:host={$host};dbname={$dbname}";
        }
        $PDO = new PDO($dsn, $username, $password, $options);

        if (!$PDO) {
            return false;
        }

        $this->PDO = $PDO;

        $this->setEscapeChar();
        return $this;
    }
public function connect ( $ type , $ host , $ dbname = '' , $ username = null , $ password = null , array $ options = array ( ) ) { if ( $ this -> PDO ) { // If this object already has a PDO object, don't attempt a new connection return $ this ; } $ dsn = '' ; if ( $ type == 'sqlite' ) { $ dsn = "{$type}:{$host}" ; } else { $ dsn = "{$type}:host={$host};dbname={$dbname}" ; } $ PDO = new PDO ( $ dsn , $ username , $ password , $ options ) ; if ( ! $ PDO ) { return false ; } $ this -> PDO = $ PDO ; $ this -> setEscapeChar ( ) ; return $ this ; }
Connect to a database

@param string $type
@param string $host
@param string $dbname [optional]
@param string $username [optional]
@param string $password [optional]
@param array $options [optional]

@return SC $this
Connect to a database