Advertisement
Guest User

Untitled

a guest
May 26th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  1. class DbAction{
  2.   public $query;
  3.   public $result;
  4.   private $connection;
  5.   public $num_rows;
  6.   private $host;
  7.   private $db_user;
  8.   private $db_password;
  9.   private $db_name;
  10.  
  11.   /*
  12.     Constructo Starts
  13.   */
  14.   public function __construct(){
  15.     $this -> connection;
  16.     $this -> query = '';
  17.     $this -> result = '';
  18.     $this -> numRows = '';
  19.     $this -> host = "localhost";
  20.     $this -> db_user = "root";
  21.     $this -> db_password = "";
  22.     $this -> db_name = "osadnicy";
  23.   }
  24.  
  25.  
  26.   /*
  27.     Starts Connection
  28.   */
  29.   public function connection(){
  30.  
  31.     $this -> connection = new mysqli($this -> host, $this -> db_user, $this -> db_password, $this -> db_name );
  32.  
  33.     if($this -> connection == true){
  34.       return true;
  35.     } else {
  36.       $this -> errorRaport();
  37.       return false;
  38.     }
  39.  
  40.   }
  41.  
  42.  
  43.  
  44.   /*
  45.     Returns result
  46.   */
  47.   public function getResult($query){
  48.     $this -> query = $query;
  49.  
  50.     if ($this -> result = mysql_query($this-> query)==true) {
  51.       return $this -> result;
  52.     } else{
  53.       return "Nie działa";
  54.     }
  55.   }
  56.  
  57.  
  58.   public function row(){
  59.     if($this -> numRows =  mysql_num_rows( $this -> result)){
  60.       return $this -> numRows;
  61.     }else{
  62.       return false;
  63.     }
  64.  
  65.   }
  66.  
  67. }
  68. $db = new DbAction();
  69. $db -> query("SELECT * FROM `uzytkownicy`");
  70. var_dump($db -> result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement