Advertisement
Guest User

Untitled

a guest
May 25th, 2012
701
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class mssqlClass {
  2.    
  3.     function connect($database = 'db') {
  4.         $mssql_server = 'server';
  5.         $mssql_data = array("UID" => 'uid',
  6.             "PWD" => 'pwd',
  7.             "Database" => $database);
  8.        
  9.         if(! ISSET ($this->connection)){
  10.             return $this->connection = sqlsrv_connect($mssql_server, $mssql_data);
  11.         }
  12.         if(! $this->connection){
  13.             return 'Failed to Connect to Host';
  14.         }
  15.     }
  16.    
  17.     function getData($query) {
  18.         $this->data_array = array();
  19.         $result = sqlsrv_query($this->connection, $query);
  20.         while ($row =  sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) {
  21.             $this->data_array[] = $row;                                                    
  22.         }
  23.         $m = $this->data_array;                
  24.         return $m;
  25.     }
  26.     function query($query) {          
  27.         $result = sqlsrv_query($query) or die( print_r( sqlsrv_errors(), true));
  28.     }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement