Created
July 11, 2014 03:38
-
-
Save makerneo-com/9c738d500a36ad80c121 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $parseDsn = function($pdoDsn) | |
| { | |
| $dsnInfo = parse_url($pdoDsn); | |
| if ( empty($dsnInfo['scheme'])) { | |
| throw new \Exception("invalid dsn:$pdoDsn"); | |
| } | |
| $pathInfo = explode(';', $dsnInfo['path']); | |
| foreach ($pathInfo as $p) { | |
| $itemInfo = explode('=', $p); | |
| if (count($itemInfo) != 2) { | |
| throw new \Exception("invalid dsn:$pdoDsn"); | |
| } | |
| $dsnInfo[$itemInfo[0]] = $itemInfo[1]; | |
| } | |
| return $dsnInfo; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment