Final Class Yiisoft\Db\Oracle\Dsn
| Inheritance | Yiisoft\Db\Oracle\Dsn |
|---|---|
| Implements | Stringable |
Represents a Data Source Name (DSN) for an Oracle Server that's used to configure a {@see Driver} instance.
To get DSN in string format, use the (string) type casting operator.
Public Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $databaseName | string | Yiisoft\Db\Oracle\Dsn | |
| $driver | string | Yiisoft\Db\Oracle\Dsn | |
| $host | string | Yiisoft\Db\Oracle\Dsn | |
| $options | array | Yiisoft\Db\Oracle\Dsn | |
| $port | string | Yiisoft\Db\Oracle\Dsn |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Db\Oracle\Dsn | |
| __toString() | Yiisoft\Db\Oracle\Dsn |
Property Details
Method Details
| public mixed __construct ( string $driver = 'oci', string $host = '127.0.0.1', string $databaseName = '', string $port = '1521', array $options = [] ) | ||
| $driver | string | |
| $host | string | |
| $databaseName | string | |
| $port | string | |
| $options | array | |
public function __construct(
public readonly string $driver = 'oci',
public readonly string $host = '127.0.0.1',
public readonly string $databaseName = '',
public readonly string $port = '1521',
public readonly array $options = [],
) {}
| public string __toString ( ) | ||
| return | string |
The Data Source Name, or DSN, contains the information required to connect to the database. Please refer to the PHP manual on the format of the DSN string. The
Will result in the DSN string |
|---|---|---|
public function __toString(): string
{
$dsn = "$this->driver:dbname=$this->host:$this->port";
if ($this->databaseName !== '') {
$dsn .= "/$this->databaseName";
}
foreach ($this->options as $key => $value) {
$dsn .= ";$key=$value";
}
return $dsn;
}
Signup or Login in order to comment.