0 follower

Abstract Class Yiisoft\Db\Driver\Pdo\AbstractPdoDriver

InheritanceYiisoft\Db\Driver\Pdo\AbstractPdoDriver
ImplementsYiisoft\Db\Driver\Pdo\PdoDriverInterface

Serves as the base class for creating PDO (PHP Data Objects) drivers.

It provides a set of common methods and properties that are implemented by the specific PDO driver classes, such as MSSQL, Mysql, MariaDb, Oracle, PostgreSQL, and SQLite.

Property Details

Hide inherited properties

$attributes protected property
protected array $attributes = []
$charset protected property
protected string|null $charset null
$dsn protected property
protected string $dsn null
$password protected property
protected string $password ''
$username protected property
protected string $username ''

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( string|\Stringable $dsn, string $username '', string $password '', array $attributes = [] )
$dsn string|\Stringable
$username string
$password string
$attributes array

                public function __construct(
    string|Stringable $dsn,
    protected string $username = '',
    #[SensitiveParameter]
    protected string $password = '',
    protected array $attributes = [],
) {
    $this->dsn = (string) $dsn;
}

            
attributes() public method

public void attributes ( array $attributes )
$attributes array

                public function attributes(array $attributes): void
{
    $this->attributes = $attributes;
}

            
charset() public method

public void charset ( string|null $charset )
$charset string|null

                public function charset(?string $charset): void
{
    $this->charset = $charset;
}

            
createConnection() public method

public PDO createConnection ( )

                public function createConnection(): PDO
{
    return new PDO($this->dsn, $this->username, $this->password, $this->attributes);
}

            
getCharset() public method

public string|null getCharset ( )

                public function getCharset(): ?string
{
    return $this->charset;
}

            
getDriverName() public abstract method
public abstract string getDriverName ( )
return string

The driver name for DB connection.

                public function getDriverName(): string;

            
getDsn() public method

public string getDsn ( )

                public function getDsn(): string
{
    return $this->dsn;
}

            
getPassword() public method

public string getPassword ( )

                public function getPassword(): string
{
    return $this->password;
}

            
getUsername() public method

public string getUsername ( )

                public function getUsername(): string
{
    return $this->username;
}

            
password() public method

public void password ( string $password )
$password string

                public function password(#[SensitiveParameter] string $password): void
{
    $this->password = $password;
}

            
username() public method

public void username ( string $username )
$username string

                public function username(string $username): void
{
    $this->username = $username;
}