Advertisement
Guest User

Untitled

a guest
May 17th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. <?
  3. class Sql{
  4.  
  5.  
  6. public $password = 'COX6KS{Q5VHKn~B8oltI0qY3zUnzPuT@PQR5M5J12@%?z0*Df6BpCWQVByXPs}~5GraEIlIuayaEEp*bYU5#a*3r3s{9OYS%*Mb';
  7. public $user = 'yaroslav';
  8. public $database = 'yaroslav';
  9. public $host = 'localhost';
  10.  
  11.  
  12. var $querydb;
  13. public $response;
  14.  
  15. function Connect_db($query, $dowhile = false){
  16.  
  17. /*ini_set('display_errors', 1); ini_set('error_reporting', E_ALL);*/
  18.  
  19. // подключаемся к серверу
  20. $link = mysqli_connect($this->host, $this->user, $this->password, $this->database)
  21.    or die(trim("Error") . mysqli_error($link));
  22. $this->querydb = $query;
  23.  
  24. $result = mysqli_query($link, $this->querydb) or die();
  25.  
  26. if($result)
  27. {
  28.  
  29.     unset($this->response);
  30.  
  31.     if($dowhile == true){
  32.             while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
  33.  
  34.  
  35.    
  36.     //return $row;
  37.  
  38.     $this->response[] = $row;
  39.     }
  40.  
  41.  
  42.     }
  43.     else{
  44.         $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
  45.         $this->response = $row;
  46.     }
  47.  
  48.     return $this->response;
  49. }
  50.  
  51. // закрываем подключение
  52. mysqli_free_result($row);
  53. mysqli_close($link);
  54. }
  55.  
  56.  
  57.  
  58. }
  59.  
  60.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement