Advertisement
Guest User

Untitled

a guest
Nov 8th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.35 KB | None | 0 0
  1. <?php
  2. class Mysql {
  3.    
  4.         private $dbuser;
  5.         private $dblocation;
  6.         private $dbpassword;
  7.         private $dbname;
  8.         private $link;
  9.         private $result=array();
  10.         function __construct($dbname)
  11.                    
  12.                     {
  13.                         $settings=parse_ini_file("setting.ini",true);
  14.                         $this->dbuser=$settings["dbconf"]["users"];
  15.                         $this->dblocation=$settings["dbconf"]["location"];
  16.                         $this->dbpassword=$settings["dbconf"]["password"];
  17.                         $this->dbname=$dbname;
  18.                         $this->link=mysql_connect("127.0.0.1","root","root") or die("Mesql connection error".mysql_erroe());
  19.                         mysql_select_db($this->dbname,$this->link) or die("Could not connection ty mysql database".mysql_error());
  20.                             //$this->result=$this->request($query);
  21.                        
  22.                    
  23.                    
  24.                     }
  25.                    
  26.                    
  27.        
  28.    
  29.     public function request($query)
  30.     {           $query=$this->toStr($query);
  31.                     $res=mysql_query($query) or die("Query failed : " . mysql_error());
  32.                     $result_arr=array();
  33.                     $p=&$result_arr;
  34.                     while ($line=mysql_fetch_array($res,MYSQL_NUM))
  35.                         {
  36.                        
  37.                         foreach ($line as $result )
  38.                             {
  39.                               $p[]=$result;
  40.                             }
  41.                         }
  42.                         return $result_arr;
  43.                     }
  44.                    
  45.                    
  46.     private function toStr($val)
  47.         {
  48.             $str=mysql_real_escape_string($val);
  49.             return $str;
  50.         }
  51.                    
  52.                    
  53.                    
  54.     public function close()
  55.     {
  56.         mysql_close($this->link);
  57.    
  58.     }
  59.    
  60.    
  61.        
  62.     }
  63.  
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement