daily pastebin goal
4%
SHARE
TWEET

Untitled

a guest Sep 19th, 2016 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Meine Config
  2. $dbhost = 'localhost';
  3. $dbuser = '';
  4. $dbpass = '';
  5. $db     = '';
  6.  
  7.  
  8. Mein Aufruf
  9. $db = new db($dbhost, $dbuser, $dbpass, $db);
  10.  
  11.  
  12.  
  13.  
  14. die klasse dazu
  15.  
  16. class db {
  17.  
  18.     var $sql_host = "";
  19.     var $sql_user = "";
  20.     var $sql_pass = "";
  21.     var $sql_base = "";
  22.     var $link_id = 0;
  23.     var $sql_count = 0;
  24.  
  25.     function db($host,$user,$pass,$base) {
  26.         $this->sql_host=$host;
  27.         $this->sql_user=$user;
  28.         $this->sql_pass=$pass;
  29.         $this->sql_base=$base;
  30.         $this->connect();
  31.     }
  32.  
  33.     function connect() {
  34.         $this->link_id=@mysqli_connect($this->sql_host,$this->sql_user,$this->sql_pass);
  35.         if(!$this->link_id) $this->error("False link == Error to connect the database");
  36.         $selecting_base=@mysqli_select_db($this->sql_base);
  37.         if(!$selecting_base) $this->error("Flase base == Error to select the database");
  38.     }
  39.  
  40.     function query($query_string) {
  41.         $selecting_query=@mysqli_query($query_string);
  42.         $this->sql_count ++;
  43.         if(!$selecting_query) $this->error("False query == $query_string");
  44.         return $selecting_query;
  45.     }
  46.  
  47.     function fetch_array($result_string) {
  48.         $selecting_result=@mysqli_fetch_array($result_string);
  49.         return $selecting_result;
  50.     }
  51.    
  52.     function fetch_object($result_string) {
  53.         $selecting_result=@mysqli_fetch_object($result_string);
  54.         return $selecting_result;
  55.     }
  56.  
  57.     function num_rows($result_string) {
  58.         $selecting_result=@mysqli_num_rows($result_string);
  59.         return $selecting_result;
  60.     }
  61.  
  62.     function unbuffered_query($query_string) {
  63.         $selecting_result=mysqli_use_result ($query_string);
  64.         if(!$selecting_result) $this->error("False query == $query_string");
  65.         return $selecting_result;
  66.     }
  67.  
  68.     function insert_id() {
  69.         $query_id=@mysqli_insert_id($this->link_id);
  70.         return $query_id;
  71.     }
  72.  
  73.     function escape_string($string){
  74.         return mysqli_real_escape_string($string);
  75.     }
  76.  
  77.     function number_of_querys() {
  78.         return $this->sql_count ;
  79.     }
  80.    
  81.     function fetch_row($result_string) {
  82.     $selecting_result=@mysqli_fetch_row($result_string);
  83.     return $selecting_result;
  84.   }
  85.  
  86.  
  87.     function error($error) {
  88.         echo ("<title>Error by Base</title>");
  89.         echo ("Error: <b>$error</b><br>\n");
  90.         #echo ("SQL-Error: ".mysqli_error()."<br>\n");
  91.         echo ("Derzeit gibt es Datenbank Probleme, bitte haben Sie etwas gedult.");
  92.         #header('Location: install.php');
  93.         exit();
  94.     }
  95.    
  96.  
  97. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand