tflori/orm

just another orm...

View the Project on GitHub tflori/orm

Build Status Test Coverage Maintainability Latest Stable Version Total Downloads

» API Reference » ORM\DbConfig

ORM\DbConfig

Table of Contents

Abstract

Describes a database configuration

Properties

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

Methods

ORM\DbConfig::__construct

public function __construct(
    string $type, 
    string $name, 
    string $user = null, 
    string $pass = null, 
    string $host = null, 
    string $port = null, 
    array $attributes = [], 
)
Constructor

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'
]);
Parameters
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

↑ top


ORM\DbConfig::getDsn

public function getDsn(): string
Get the data source name
Returns string  

ORM\DbConfig::getDsn

↑ top