I dread writing this post and keep putting it off, but I have to get it out of the way before completing my web site upgrade.
After experimenting with dozens of different designs, I decided that the best way to handle PDO database connection in PHP is to encapsulate the PDO object in a procedure.
The Design Pattern crowd labels this approach an anti-pattern and a dependency injection.
The two pieces of code that I am publishing are: A notification which I am calling msgNote and a procedure that encapsulates the PDO connection called dbMain().
Together these two programs have 200 lines of code ... a third of the lines are comments.
WARNING: This morning I decided to change the error handing on dbMain(). I have not tested the program fully. Expect dbMain() to change as I run it through tests on this, my test server.
The program is in a test phase. I welcome comments on this page or on my disqus widget.