<?php

include 'parameters.php';

class connectionController
{

    public function getPdo()
    {
        try {

            $parameters = new appParameters();

            $hostname = $parameters->insertGT_hostname;
            $dbname = $parameters->insertGT_dbname;
            $username = $parameters->insertGT_username;
            $password = $parameters->insertGT_password;

            return $pdo = new PDO("sqlsrv:Server=$hostname;Database=$dbname", "$username", "$password");



        } catch (PDOException $e) {
            echo 'Połączenie nie mogło zostać utworzone: ' . $e->getMessage();
        }
    }

    public function sferaConnect(){

        $parameters = new appParameters();

        $gt = new COM("InsERT.GT") or die("Cannot create an InsERT GT object");
        $gtd = new COM("InsERT.Dodatki") or die("Cannot create an InsERT.Dodatki object");
        //$gtb = new COM("InsERT.Braki") or die("Cannot create an InsERT.Braki object");

        $gt->Produkt = 1;
        $gt->Serwer = $parameters->sfera_server;
        $gt->Baza = $parameters->sfera_database;
        $gt->Autentykacja = 0;
        $gt->Uzytkownik = $parameters->sfera_user;
        $gt->UzytkownikHaslo = $parameters->sfera_user_password;
        $gt->Operator = $parameters->sfera_operator;
        $gt->OperatorHaslo = $gtd -> Szyfruj($parameters->sfera_operator_password);
        return $gt->Uruchom(0, 6);
    }
}

?>
