connection ) { return; } // data for making connection $mssql_server = $_ENV['PEC_DB_HOST']; $mssql_data = array("UID" => $_ENV['PEC_DB_USER'], "PWD" => $_ENV['PEC_DB_PASS'], "Database" => $_ENV['PEC_DB_NAME']); // try to connect $this->connection = sqlsrv_connect($mssql_server, $mssql_data); if(! $this->connection){ return 'Failed to connect to host'; } } public function getData ($query) { // reset results; is this really needed as object's variable? Can't it be just local function's variable?? $this->data_array = array(); $result = $this->query($query); while ($row = sqlsrv_fetch_array($result)) { $this->data_array[] = $row; } return $this->data_array; } public function query($query) { $result = sqlsrv_query($this->connection, $query) or die("This Query didn't work.. [QUERY = ".$query."]"); return $result; } }