Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1.  
  2. <?
  3. class Sql{
  4.  
  5. public $password = '';
  6. public $user = '';
  7. public $database = '';
  8. public $host = '';
  9. var $querydb;
  10. public $response;
  11.  
  12. function Connect_db($query, $dowhile){
  13.  
  14. /*ini_set('display_errors', 1); ini_set('error_reporting', E_ALL);*/
  15.  
  16. // подключаемся к серверу
  17. $link = mysqli_connect($this->host, $this->user, $this->password, $this->database)
  18.     or die(trim("Error") . mysqli_error($link));
  19. $this->querydb = $query;
  20.  
  21. $result = mysqli_query($link, $this->querydb) or die("Error" . mysqli_error($link));
  22.  
  23. if($result)
  24. {
  25.  
  26.     if($dowhile == true){
  27.             while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
  28.  
  29.  
  30.     $i++;
  31.     //return $row;
  32.     $this->response[$i] = $row;
  33.     }
  34.  
  35.  
  36.     }
  37.     else{
  38.         $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
  39.         $this->response = $row;
  40.     }
  41.  
  42.     return $this->response;
  43. }
  44.  
  45. // закрываем подключение
  46.  
  47. mysqli_close($link);
  48. }
  49.  
  50.  
  51.  
  52. }
  53.  
  54.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement