Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class DatabaseConnection
- {
- protected $hostname;
- protected $database;
- protected $username;
- protected $password;
- /**
- * hostname setzen
- * @param string hostname
- */
- public function setHostname($hostname)
- {
- $this->hostname = $hostname;
- }
- /**
- * db setzen
- * @param string database
- */
- public function setDatabase($database)
- {
- $this->database = $database;
- }
- /**
- * sets username
- * @param string username
- */
- public function setUsername($username)
- {
- $this->username = $username;
- }
- /**
- * sets password
- * @param string password
- */
- public function setPassword($password)
- {
- $this->password = $password;
- }
- /**
- * return mysqliobj
- * @return mysqli
- */
- public function getConnection()
- {
- return new mysqli($this->hostname, $this->username, $this->password, $this->database);
- if (!mysqli_connect_errno()) {
- throw new Exception('Error: ' .mysqli_connect_errno());
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment