Doctrine – Special Characters in DSN Database Connection String

I couldn’t seem to get one of my connections to work in a recent project and thought that I was doing everything correctly in my Zend application.ini file.

The password had special characters in it, one of them being a character used for other purposes inside of a dsn connection string. So I needed to add some HEX to my connection string to replace the special char. All this info is listed inside the doctrine ORM documentation and was easy to find once I figured out the problem. The following characters need to be replace with their corresponding hex value inside your application.ini:

Character Hex Code
: – %3a
/ – %2f
@ – %40
+ – %2b
( – %28
) - %29
? – %3f
= – %3d
& – %26

Example Application INI connection string:

doctrine.db1 = “mysql://username:pass%2bword@”

Doctrine DSN Documentation

Tuesday, September 29th, 2009 Doctrine

Leave a Reply

You must be logged in to post a comment.

[ad code=1 align=center]