Best practice-creating a good PDO connection
Please, never use procedural code-style with object oriented libraries.
For php5+: this is not good code-style, please, see article about Object Oriented Programming; for php5-: this is tolerable variant(but I don't remember if php4 has had PDO).

After learning something about OOP, try to read something about MVC(Model-View-Controller) and Design Patterns(ex.: "GOF: Design Patterns")

P.S. Sorry if it seems roughly for you. But if you want to write best code - it's the only way.