Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.46 KB | None | 0 0
  1. <?php
  2.    
  3.     class db{
  4.         public $connection;
  5.         public $server;
  6.         public $port;
  7.         public $username;
  8.         public $password;
  9.         public $database;
  10.        
  11.         //CORE
  12.         public function __construct($server, $username, $password, $database, $port = false, $preserve = false)
  13.         {
  14.            
  15.             $this->server = $server;
  16.             $this->username = $username;
  17.             $this->password = $password;
  18.             $this->database = $database;
  19.            
  20.             if($port === false)
  21.             {
  22.                 $port = 3306;
  23.                 $this->port = $port;
  24.             }
  25.            
  26.             if($preserve)
  27.             {
  28.                 $this->connection = mysql_pconnect($this->server.':'.$this->port, $this->username, $this->password);
  29.             }
  30.             else
  31.             {
  32.                 $this->connection = mysql_connect($this->server.':'.$this->port, $this->username, $this->password);
  33.             }
  34.            
  35.             if($this->connection)
  36.             {
  37.                 mysql_select_db($this->database, $this->connection);
  38.             }
  39.         }
  40.        
  41.         public function __destruct()
  42.         {
  43.             mysql_close($this->connection);
  44.         }
  45.        
  46.         //REQUEST
  47.         public function sql_query($sql)
  48.         {
  49.             return mysql_query($sql, $this->connection);
  50.         }
  51.        
  52.         public function sql_search($search)
  53.         {
  54.             $search = mysql_real_escape_string($search, $this->connection);
  55.             $sql = "SELECT * FROM wikpost
  56.                     WHERE MATCH (pTopic, pText)
  57.                     AGAINST ('".$search."')";
  58.             $query = mysql_query($sql, $this->connection);
  59.            
  60.             return mysql_fetch_array($query);
  61.         }
  62.        
  63.         public function sql_escape($sql)
  64.         {
  65.             return mysql_real_escape_string($sql, $this->connection);
  66.         }
  67.     }
  68.    
  69. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement