Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * $dbase = db::getDB();
- *
- */
- class db
- {
- public $db_host = false;
- public $db_name = false;
- public $db_user = false;
- public $db_pass = false;
- protected $dbi = false;
- private static $instance;
- public static function getDB()
- {
- if (!isset(self::$instance))
- {
- self::$instance = new db();
- }
- return self::$instance;
- }
- protected function __construct()
- {
- include (__PWC_DIR_CONFIG_MT__ . '/config.php');
- $this->db_host = $dbhost;
- $this->db_name = $dbname;
- $this->db_user = $dbuser;
- $this->db_pass = $dbpass;
- $this->prefix = (empty($prefix) ? 'mt' : $prefix);
- }
- private function __clone()
- {
- die ('Bitte die vorhandene Instanz nutzen "$dabse = db::getDB();" / Please use the instance "$dabse = db::getDB();"');
- }
- public function sql_connect()
- {
- if (!is_resource($this->dbi))
- {
- $this->dbi = @mysql_connect($this->db_host, $this->db_user, $this->db_pass);
- }
- $this->sql_select_db();
- return $this->dbi;
- }
- public function sql_select_db()
- {
- if (!is_resource($this->dbi))
- {
- if (mysql_errno() == 1045)
- {
- $error_message[] = '(1045) Die Benutzerdaten zur Datenbank sind falsch angegeben!';
- }
- elseif (mysql_errno() == 2005)
- {
- $error_message[] = '(2005) Der Datenbank-Host ist falsch angegeben!';
- }
- else
- {
- $error_message[] = mysql_error();
- }
- }
- if (!isset($error_message))
- {
- $isdb = @mysql_select_db($this->db_name, $this->dbi);
- if (!$isdb)
- {
- if (mysql_errno() == 1049)
- {
- $error_message[] = '(1049) Der Datenbank-Name ist falsch angegeben!';
- }
- else
- {
- $error_message[] = mysql_error();
- }
- }
- }
- if (isset($error_message))
- {
- arsort($error_message);
- die ('<html><head><title>' . __PWC_NAME__ . ' v' . __PWC_VERSION__ . ' - Datenbank-Fehler</title></head><body text="#000000"><h2>' . __PWC_NAME__ . ' v' . __PWC_VERSION__ . ' - Datenbank-Fehler</h2><b>Sorry, wir haben zur Zeit Probleme mit der Datenbank. (' . mysql_errno() . ')</b><br /><br /><lu><li>' . implode('</li><li>', $error_message) . '<br /><br />' . __POWERED__ . '</body></html>');
- }
- return $this->dbi;
- }
- public function sql_logout()
- {
- return true;
- }
- public function sql_insert_id()
- {
- return @mysql_insert_id($this->dbi);
- }
- public function sql_affected_rows()
- {
- return intval(@mysql_affected_rows($this->dbi));
- }
- public function sql_query($query)
- {
- $result = @mysql_query($query, $this->dbi);
- // if (mysql_errno() == 1146)
- // {
- // die ('<html><head><title>' . __PWC_NAME__ . ' v' . __PWC_VERSION__ . ' - Datenbank-Fehler</title></head><body text="#000000"><h2>' . __PWC_NAME__ . ' v' . __PWC_VERSION__ . ' - Datenbank-Fehler</h2><b>Sorry, wir haben zur Zeit Probleme mit der Datenbank.</b><br /><br />' . mysql_errno($this->dbi) . ': ' . mysql_error($this->dbi) . '<br /><br />' . __POWERED__ . '</body></html>');
- // }
- return $result;
- }
- public function sql_num_rows($result)
- {
- $rows = intval(@mysql_num_rows($result));
- return $rows;
- }
- public function sql_fetch_row($result)
- {
- $row = array();
- $row = @mysql_fetch_row($result);
- return $row;
- }
- public function sql_fetch_array($result)
- {
- $row = array();
- $row = @mysql_fetch_array($result);
- return $row;
- }
- public function sql_fetch_assoc($result)
- {
- $row = array();
- $row = @mysql_fetch_assoc($result);
- return $row;
- }
- public function sql_fetch_object($result)
- {
- $row = @mysql_fetch_object($result);
- return ($row == false) ? false : $row;
- }
- public function sql_fetch_rowset($result)
- {
- $rowset = array();
- $row = @mysql_fetch_array($result, MYSQL_ASSOC);
- while ($row)
- {
- $rowset[] = $row;
- $row = @mysql_fetch_array($result, MYSQL_ASSOC);
- }
- return $rowset;
- }
- public function sql_free_result($result)
- {
- $row = @mysql_free_result($result);
- return $row;
- }
- public function sql_data_seek($what, $result)
- {
- return @mysql_data_seek($what, $result);
- }
- public function sql_result($result, $number, $what)
- {
- return @mysql_result($result, $number, $what);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement