yep / dsn
DSN string helper
dev-master
2016-06-13 19:35 UTC
Requires
- php: >=7.0.0
Requires (Dev)
- phpunit/phpunit: 5.3.*
This package is auto-updated.
Last update: 2024-12-11 19:12:39 UTC
README
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');