SHARE
TWEET

Untitled

a guest Oct 23rd, 2017 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php namespace Database;
  2.  
  3.  
  4. class MySQL{
  5.     private $servername = "203.146.44.187";
  6.     private $username = "user";
  7.     private $password = "admin@1234";
  8.     private $dbName = "cu_bank";
  9.  
  10.     public function query(string $queryString){
  11.         $response = array("isError" => false,"message" => '',"data" => array());
  12.         $conn = mysqli_connect($this->servername,$this->username,$this->password,$this->dbName);
  13.         if(!$conn){
  14.           $response["isError"] = true;
  15.           $response["message"] = "connection error";
  16.           $response["description"] = mysqli_error($conn);
  17.           return $response;
  18.         }
  19.         $result = mysqli_query($conn,$queryString);
  20.         if(mysqli_error($conn)){
  21.           $response["isError"] = true;
  22.           $response["message"] = "query error";
  23.           $response["description"] = mysqli_error($conn);
  24.         }
  25.         else{
  26.           $data = array("count" => 0, "records" => array());
  27.           $data["count"] = mysqli_num_rows($result);
  28.  
  29.           for($ct = $data["count"];$ct > 0;$ct--){
  30.             array_push($data["records"], mysqli_fetch_array($result,MYSQLI_ASSOC));
  31.           }
  32.           $response["data"] = $data;
  33.         }
  34.         mysqli_close($conn);
  35.         return $response;
  36.     }
  37.  
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top