just another orm...
View the Project on GitHub tflori/orm
» API Reference » ORM\DbConfig
Visibility | Name | Type | Description |
---|---|---|---|
public | $type |
string | Dabase Type (mysql, pgsql or sqlite) |
public | $name |
string | Database name or path for sqlite |
public | $host |
string | Hostname or ip address |
public | $port |
string | Port for DBMS (defaults to 3306 for mysql and 5432 for pgsql) |
public | $user |
string | Database user |
public | $pass |
string | Database password |
public | $attributes |
array | PDO attributes |
public function __construct(
string $type,
string $name,
string $user = null,
string $pass = null,
string $host = null,
string $port = null,
array $attributes = [],
)
The constructor gets all parameters to establish a database connection and configure PDO instance.
Example:
$dbConfig = new DbConfig('mysql', 'my_db', 'my_user', 'my_secret', null, null, [
\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
]);
Parameter | Type | Description |
---|---|---|
$type |
string | Type of database (currently supported: mysql , pgsql and sqlite ) |
$name |
string | The name of the database or the path for sqlite |
$user |
string | Username to use for connection |
$pass |
string | Password |
$host |
string | Hostname or IP address - defaults to localhost |
$port |
string | Port - default ports (mysql: 3306, pgsql: 5432) |
$attributes |
array | Array of PDO attributes |
ORM\DbConfig::__construct
public function getDsn(): string
Returns | string |
ORM\DbConfig::getDsn