Saving my PDO connection as a global variable [duplicate]
问题 This question already has answers here : How to properly set up a PDO connection (4 answers) Closed 6 years ago . While asking another questions about PDO queries, I've been told that saving my PDO connection object as global to use it in my various functions that call queries to my database is generally bad practice. Here is how I generally use my PDO object: function somefunction(){ global $pdo; $statement = $pdo->prepare("some query"); $statement->execute(); } The arguments I've read are