Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- class Sql{
- public $password = '';
- public $user = '';
- public $database = '';
- public $host = '';
- var $querydb;
- public $response;
- function Connect_db($query, $dowhile){
- /*ini_set('display_errors', 1); ini_set('error_reporting', E_ALL);*/
- // подключаемся к серверу
- $link = mysqli_connect($this->host, $this->user, $this->password, $this->database)
- or die(trim("Error") . mysqli_error($link));
- $this->querydb = $query;
- $result = mysqli_query($link, $this->querydb) or die("Error" . mysqli_error($link));
- if($result)
- {
- if($dowhile == true){
- while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
- $i++;
- //return $row;
- $this->response[$i] = $row;
- }
- }
- else{
- $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
- $this->response = $row;
- }
- return $this->response;
- }
- // закрываем подключение
- mysqli_close($link);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement