Reputation: 194
I am trying to find a way which does the following
closing a connection anyways
<?php
define("HOST", "localhost");
define("USER", "username");
define("PASS", "password");
define("DBNM", "database");
class ConnectionTest extends mysqli {
private $link;
function __construct() {
$this->link = new mysqli(HOST, USER, PASS, DBNM);
}
function getLink(){
return $this->link;
}
function __destruct() {
mysqli_close($this->link)
}
}
?>
To try to get to my objective
As I am new to PHP, I would like to know:
Upvotes: 0
Views: 1291
Reputation: 158003
Frankly, this class of yours makes very little sense as it effectively duplicates mysqli. All the things you want to achieve, are already implemented in mysqli:
So I fail to see how is your class any better than mysqli.
Upvotes: 1