So I’m building an OOP project for the first time.
I have a class called DBH (database handler). Here I have private properties for my connection and a public method called “connect”.
This method returns a connection.
[code]
$con = new mysqli($this->servername, $this->username, $this->password, $this->dbname);
return $con;
all over my website I call other classes and methods which use this, in each method I have a connection like this
[code]
$Db = new Dbh;
$con = $Db->connect();
I don’t ever close it.
occasionally I get the above error, I’m not sure if it’s my code and too many connections or if it’s my shared hosting.
is there anything I should do to improve my side of things?