Advertisement
Guest User

Untitled

a guest
Sep 16th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.87 KB | None | 0 0
  1. <?php
  2. /*
  3.  
  4.  *
  5.  *  */
  6.  
  7. class Mysql_Con {
  8. // Urceny promenych
  9. public $debug=1;
  10. public $db_name;
  11. public $db_host;
  12. public $db_user;
  13. public $db_pass;
  14. protected $relation;
  15. protected $result;
  16. protected $query=array();
  17. protected $query_indetifier;
  18. public $debug_var=TRUE; // nastavit na true jestli chcete aby byla result array rovnou vypsana
  19. //funkce pro nastavení promenych
  20. function setlogin($name,$host,$pass,$user){
  21.     $this->db_host=$host;
  22.     $this->db_name=$name;
  23.     $this->db_pass=$pass;
  24.     $this->db_user=$user;
  25.  
  26.     return $this;
  27.    
  28. }
  29. function connect(){
  30.     $this->relation=mysqli_connect($this->db_host, $this->db_user, $this->db_pass, $this->db_name) or die(mysqli_error($this->relation));
  31.     return $this;
  32. }
  33. function disconnect(){
  34.     mysqli_close($this->relation) or die(mysqli_error($this->relation));
  35.     return $this;
  36. }
  37. }
  38. class mysql_Query extends Mysql_Con {
  39.     function append($input){
  40.         $this->query[$this->query_indetifier].=" ".$input;
  41.         return $this;
  42.     }
  43.     function setQuery($input){
  44.         if(array_key_exists($input, $this->query)):
  45.             $this->query_indetifier=$input;
  46.         else:
  47.             $this->query[$input]="";
  48.             $this->query_indetifier=$input;
  49.         endif;
  50.         return $this;
  51.     }
  52.    
  53.     function select(){
  54.         $this->result=mysqli_query($this->relation, $this->query[$this->query_indetifier]) or die(mysqli_error($this->relation));
  55.         return $this;
  56.     }
  57.     /*function insert(){
  58.        
  59.        
  60.     }*/
  61.     function result(){
  62.         $this->result=mysqli_fetch_array($this->result) or die(mysqli_error($this->relation));
  63.             if($this->debug_var == TRUE):
  64.                 echo '<p style="background-color: gray; color:white">';
  65.                 print_r($this->result);
  66.                 echo '</p>';
  67.             endif;
  68.         return $this;
  69.     }
  70. }
  71. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement