Quote Originally Posted by aaarrrggh View Post
But the challenge is to pass around the database connection in a procedural style without using globals. This function would do it - if you call it after the db is created, you'll just receive the handle. If the handle isn't created already, the connection will be made and the handle will be returned.

I'm not sure I agree a new connection should be created each time anyway. It'd be more resource heavy, unless you're planning to just pass the database handle around all over the place?
1) I'm not participating in your challenge.
2) My way does not require a new DB connection, it requires one. You reuse the object that was created.