yep/dsn

DSN string helper

dev-master 2016-06-13 19:35 UTC

This package is auto-updated.

Last update: 2024-10-11 18:51:55 UTC


README

Build Status Scrutinizer Code Quality Scrutinizer Code Coverage Latest Stable Version Total Downloads License

Dsn

Packagist

Dsn is available on Packagist.org, just add the dependency to your composer.json.

{
  "require" : {
    "yep/dsn": "dev-master"
  }
}

Usage

You can use MySqlDsn, MySqlUnixSocketDsn, PostgreSqlDsn, Sqlite2Dsn or SqliteDsn.

<?php
$dsn = new Yep\Dsn\MySqlDsn(
  $dbName = 'database',
  $host = 'localhost',
  $port = 3306
);

echo $dsn->toString(); // mysql:host=localhost;dbname=database;port=3306
// or
echo $dsn; // mysql:host=localhost;dbname=database;port=3306

// Usage with PDO
$pdo = new PDO($dsn, 'root');