bluefrg/parsepdodsn

A class for parsing PHP's PDO strings.

1.0.0 2019-09-04 22:23 UTC

This package is auto-updated.

Last update: 2024-04-05 08:42:55 UTC


README

A simple library to parse and interpret a PDO DSN string.

<?php
$dsn = Bluefrg\ParsePdoDsn\Dsn::parse('mysql:host=localhost;dbname=testdb');

// Get the prefix
echo $dsn->getPrefix(); // mysql

// Fetch an element's value 
echo $dsn->element('host'); // localhost 
echo $dsn->element('dbname'); // testdb

// List all elements as key-values
print_r($dsn->getElements()); 

Install

$ composer require bluefrg/parsepdodsn