Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class DBConn implements IDBConn {
- private $_db=0;
- private $DB_HOST;
- private $DB_USER;
- private $DB_PASSWORD;
- private $DB_NAME;
- //----------------------------------
- public function connect() {
- $this->_db = @new mysqli ($this->DB_HOST, $this->DB_USER, $this->DB_PASSWORD, $this->DB_NAME );
- if ($this->_db->connect_errno) {
- throw new Exception('connection error '.$this->_db->connect_error);
- }
- }
- //----------------------------------
- public function set($DB_HOST, $DB_USER, $DB_PASSWORD, $DB_NAME) {
- $this->DB_HOST = $DB_HOST;
- $this->DB_USER = $DB_USER;
- $this->DB_PASSWORD = $DB_PASSWORD;
- $this->DB_NAME = $DB_NAME;
- }
- //----------------------------------
- public function get() {
- if ($this->_db===0) {
- $this->connect();
- }
- return $this->_db;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement