The following code snippet shows how you can parse a DSN (Data Source Name). Why is it useful? You can now pass a single DSN parameter to your database wrapper class' constructor (instead of five separate parameters), and tear it apart into the components you need. The password and port are considered optional. You may need to tweak the regex if you use other characters than letters, digits or underscores. Questions? Ask!