Classes and Database Connection reuse
I have a php file that has all my database credentials using PDO.
I have a class file that contains all my classes. In the class file I find myself creating the database connection in every function:
class myClass {
/* Properties */
private $conn;
/* Get database access */
public function __construct(\PDO $pdo) {
$this->conn = $pdo;
}
}
What should I be doing so that I am not doing this in every class?