Advertisement
Guest User

Untitled

a guest
May 15th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. <?php
  2.  
  3. class MySQLConnection
  4. {
  5.    function __construct($host, $username, $password)
  6.    {
  7.        $this->host = $host;
  8.        $this->username = $username;
  9.        $this->password = $password;
  10.    }
  11.  
  12.    function connect()
  13.    {
  14.        $this->connection = mysql_connect($this->host, $this->username, $this->password = $password;) or die("Cannot establish connection to MySQL Server.");
  15.    }
  16.  
  17.    function selectDatabase($database)
  18.    {
  19.        $db = mysql_select_db($database, $this->connection) or die("Cannot select the database.");
  20.    }
  21.  
  22.    function executeQuery($query)
  23.    {
  24.        return mysql_query($query);
  25.    }
  26.  
  27.    function getNumRows($query)
  28.    {
  29.         return mysql_num_rows(executeQuery($query));
  30.    }
  31. }
  32.  
  33.  
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement