Guest User

Untitled

a guest
Dec 4th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. <?php
  2.     ini_set ('display_errors', 'On');
  3.     class mysqldb
  4.     {
  5.         private $result = NULL;
  6.         private $connection = NULL;
  7.         function __construct($host=NULL, $database=NULL, $user=NULL, $pass=NULL)
  8.         {
  9.             $this->connection = mysql_connect($host,$user,$pass) or die("Error bei der Verbindung");
  10.             mysql_select_db($database, $this->connection) or die("Error bei der Datenbank");
  11.         }
  12.         function disconnect()
  13.         {
  14.             if(is_resource($this->connection))
  15.             {
  16.                 mysql_close($this->connection);
  17.             }
  18.         }
  19.         function sendquery($query)
  20.         {
  21.             $this->result = mysql_query($query, $this->connection) or die(mysql_errno($this->connection));
  22.         }
  23.         function fetchRow()
  24.         {
  25.             return mysql_fetch_assoc($this->result) or die(mysql_errno($this->connection));
  26.         }
  27.     }
  28.     $mysql1 = new mysqldb("localhost", "database", "user", "pass");
  29.     $mysql1->sendquery("SELECT * FROM a");
  30.     while($row = $mysql1->fetchRow())
  31.     {
  32.         echo $row["id"];
  33.     }
  34. ?>
Add Comment
Please, Sign In to add comment