So I have implemented lazy-load connecting to the database - only connecting when a query is actually being done.

Sometimes we end up only using a cache so its a waste to actually open the connection to the DB server...

The problem I have run into is with escaping arguments - mysql_real_escape_string can no longer be used but mysql_escape_string is deprecated.

Does anyone have any suggestions to approach this issue and how I might be able to solve it?

Look forward to all ideas and suggestions!