Example #1
1
 public function Query($Procedimiento, $RetornaDatos, $arrayValores = "")
 {
     $parametros = array();
     $NombreServidor = constant("sqlHost");
     $InfoConexion = array("UID" => constant("sqlUsuario"), "PWD" => constant("sqlContrasena"), "Database" => $this->NombreBaseDatos);
     $conn = sqlsrv_connect($NombreServidor, $InfoConexion);
     if (is_array($arrayValores)) {
         $stringInterrogacion = "(?";
         for ($i = 1; $i < count($arrayValores); $i++) {
             $stringInterrogacion .= ",?";
         }
         $stringInterrogacion .= ")";
         $Procedimiento = "{call " . $Procedimiento . " " . $stringInterrogacion . "}";
         for ($i = 0; $i < count($arrayValores); $i++) {
             array_push($parametros, array($arrayValores[$i], SQLSRV_PARAM_IN));
         }
     } else {
         $Procedimiento = "{call " . $Procedimiento . "}";
     }
     $stmt3 = sqlsrv_query($conn, $Procedimiento, $parametros);
     if ($RetornaDatos) {
         $array = array();
         while ($obj = sqlsrv_fetch_array($stmt3, SQLSRV_FETCH_ASSOC)) {
             $array[] = $obj;
         }
         return $array;
         sqlsrv_free_stmt($stmt3);
     }
     sqlsrv_close($conn);
 }
Example #2
1
 /**
  * Establishes a connection to the database.
  * Includes php_interface/after_connect_d7.php on success.
  * Throws exception on failure.
  *
  * @return void
  * @throws \Bitrix\Main\DB\ConnectionException
  */
 protected function connectInternal()
 {
     if ($this->isConnected) {
         return;
     }
     $connectionInfo = array("UID" => $this->login, "PWD" => $this->password, "Database" => $this->database, "ReturnDatesAsStrings" => true);
     if (($this->options & self::PERSISTENT) != 0) {
         $connectionInfo["ConnectionPooling"] = true;
     } else {
         $connectionInfo["ConnectionPooling"] = false;
     }
     $connection = sqlsrv_connect($this->host, $connectionInfo);
     if (!$connection) {
         throw new ConnectionException('MS Sql connect error', $this->getErrorMessage());
     }
     $this->resource = $connection;
     $this->isConnected = true;
     // hide cautions
     sqlsrv_configure("WarningsReturnAsErrors", 0);
     /** @noinspection PhpUnusedLocalVariableInspection */
     global $DB, $USER, $APPLICATION;
     if ($fn = \Bitrix\Main\Loader::getPersonal("php_interface/after_connect_d7.php")) {
         include $fn;
     }
 }
 /**
  * Connects to a database.
  * @return void
  * @throws Dibi\Exception
  */
 public function connect(array &$config)
 {
     Helpers::alias($config, 'options|UID', 'username');
     Helpers::alias($config, 'options|PWD', 'password');
     Helpers::alias($config, 'options|Database', 'database');
     Helpers::alias($config, 'options|CharacterSet', 'charset');
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } else {
         $options =& $config['options'];
         // Default values
         if (!isset($options['CharacterSet'])) {
             $options['CharacterSet'] = 'UTF-8';
         }
         $options['PWD'] = (string) $options['PWD'];
         $options['UID'] = (string) $options['UID'];
         $options['Database'] = (string) $options['Database'];
         $this->connection = sqlsrv_connect($config['host'], $options);
     }
     if (!is_resource($this->connection)) {
         $info = sqlsrv_errors();
         throw new Dibi\DriverException($info[0]['message'], $info[0]['code']);
     }
     $this->version = sqlsrv_server_info($this->connection)['SQLServerVersion'];
 }
Example #4
0
 private function connect()
 {
     $this->conn = sqlsrv_connect($this->server, array("Database" => $this->db, "UID" => $this->user, "PWD" => $this->pw));
     if ($this->conn === false) {
         die(print_r(sqlsrv_errors(), true));
     }
 }
Example #5
0
 private function getDbConnect($address, $account, $pwd, $name)
 {
     if (DB_TYPE == 'mssql') {
         return mssql_connect($address, $account, $pwd);
     }
     if (DB_TYPE == 'sqlsrv') {
         if (defined('DBITPro_Dev')) {
             $connectionInfo = array("UID" => $account, "PWD" => $pwd, "Database" => $name);
         } else {
             $connectionInfo = array("UID" => $account, "PWD" => $pwd, "Database" => $name);
         }
         $conn = sqlsrv_connect($address, $connectionInfo);
         if (false === $conn) {
             echo "Could not connect.\n";
             die(print_r(sqlsrv_errors(), true));
         }
         return $conn;
     }
     if (DB_TYPE == 'mysql') {
         $conn = mysql_connect($address, $account, $pwd);
         if (false === $conn) {
             echo "Could not connect.\n";
             die(print_r(mysql_errors(), true));
         }
         return $conn;
     }
 }
Example #6
0
 public function Ymssql($url)
 {
     $url = parse_url($url);
     // Check if SQLSRV support is present in PHP
     if (!function_exists('sqlsrv_connect')) {
         die('Unable to use the Microsoft SQL Server database because the SQLSRV extension for PHP is not installed. Check your <code>php.ini</code> to see how you can enable it.');
     }
     // Decode url-encoded information in the db connection string
     $url['user'] = urldecode($url['user']);
     // Test if database url has a password.
     $url['pass'] = isset($url['pass']) ? urldecode($url['pass']) : '';
     $url['host'] = urldecode($url['host']);
     $url['path'] = urldecode($url['path']);
     // Allow for non-standard port.
     if (isset($url['port'])) {
         $url['host'] = $url['host'] . ', ' . $url['port'];
     }
     $connectionInfo = array("Database" => substr($url['path'], 1), "UID" => $url['user'], "PWD" => $url['pass']);
     $connection = @sqlsrv_connect($url['host'], $connectionInfo);
     if (!$connection) {
         // Show error screen otherwise
         throw new Exception(print_r(sqlsrv_errors(), true));
     }
     $this->lnk = $connection;
 }
Example #7
0
function getDentrix()
{
    #	PHPinfo();
    $connInfo = array("Database" => "dentrix", "UID" => "jl149", "PWD" => "l3tm31n", "ReturnDatesAsStrings" => true);
    $dentrix = sqlsrv_connect("192.168.14.55,1435", $connInfo);
    return $dentrix;
}
Example #8
0
 /**
  * @return false|mysqli|resource
  */
 public function connect()
 {
     try {
         if ($this->DRIVER == "sqlsrv") {
             $server_name = $this->HOST_NAME . "," . $this->PORT;
             $dbection_info = array("Database" => $this->DATABASE, "UID" => $this->USER, "PWD" => $this->PASSWORD);
             $db = sqlsrv_connect($server_name, $dbection_info);
             if ($db === false) {
                 die(print_r(sqlsrv_errors(), true));
             } else {
                 return $db;
             }
         } else {
             if ($this->DRIVER == "mysqli") {
                 $db = new mysqli($this->HOST_NAME, $this->USER, $this->PASSWORD, $this->DATABASE, $this->PORT);
                 if ($db->connect_error) {
                     die('Connect Error (' . $db->connect_errno . ') ' . $db->connect_error);
                 }
                 return $db;
             } else {
                 die("Driver not found!");
             }
         }
     } catch (Exception $e) {
         var_dump("Error: {$e->getMessage()}");
         return;
     }
 }
Example #9
0
function GetFacultyQuestions($groupid)
{
    include_once 'db_Connection.php';
    $conn = sqlsrv_connect($serverName, $connectionInfo);
    $questionvalues = array();
    $questions = array();
    $faculty = array();
    $facultyquestions = array();
    if ($conn) {
        //----get acadyear-------------------
        $acid = 0;
        $sqlstr = " SELECT [AcadYearID] FROM [dbo].[Groups] where [groupid]=? ";
        $params = array($groupid);
        $sqlquery = sqlsrv_query($conn, $sqlstr, $params);
        if ($sqlquery) {
            while ($row = sqlsrv_fetch_array($sqlquery, SQLSRV_FETCH_ASSOC)) {
                $acid = $row['AcadYearID'];
            }
            sqlsrv_free_stmt($sqlquery);
        }
        $sqlstr = " SELECT [questionTypeId],[value],[text] " . " FROM [dbo].[QuestionValues] " . " order by questionTypeId ";
        //  $params = array ($acid);
        $sqlquery = sqlsrv_query($conn, $sqlstr);
        if ($sqlquery) {
            while ($row = sqlsrv_fetch_object($sqlquery)) {
                $questionvalues[] = $row;
            }
            sqlsrv_free_stmt($sqlquery);
        }
        //----get question array-------------------
        $sqlstr = " SELECT [QuestionID],[QueastionText],[questionType],[maxmark],-1 as mark,'' as description " . " FROM [dbo].[Questions] " . " where [QuestionLecturer]=0 " . " and [Acadyear]=? ";
        $params = array($acid);
        $sqlquery = sqlsrv_query($conn, $sqlstr, $params);
        if ($sqlquery) {
            while ($row = sqlsrv_fetch_object($sqlquery)) {
                $row->questionValues = array();
                foreach ($questionvalues as &$questValue) {
                    if ($questValue->questionTypeId === $row->questionType) {
                        array_push($row->questionValues, $questValue);
                    }
                }
                $questions[] = $row;
            }
            sqlsrv_free_stmt($sqlquery);
        }
        //----get faculty-------------------
        $sqlstr = " SELECT [FacultyID],[FacultyName] FROM [dbo].[Groups] " . " where [groupid]=? ";
        $params = array($groupid);
        $sqlquery = sqlsrv_query($conn, $sqlstr, $params);
        if ($sqlquery) {
            while ($row = sqlsrv_fetch_object($sqlquery)) {
                $row->quests = $questions;
                $faculty[] = $row;
            }
            $facultyquestions = array("result" => 0, "data" => $faculty);
        }
        sqlsrv_close($conn);
    }
    return $facultyquestions;
}
 public function AttemptConnection()
 {
     if (empty($this->type)) {
         return false;
     } elseif ($this->type == "MySQL") {
         $this->connection = mysqli_connect($this->address, $this->username, $this->password, $this->database);
         if (!$this->connection) {
             $this->lastErrorMessage = "Error: Unable to connect to MySQL." . PHP_EOL . "Debugging errno: " . mysqli_connect_errno() . PHP_EOL . "Debugging error: " . mysqli_connect_error() . PHP_EOL;
             return false;
         }
         //SQL Server
     } elseif ($this->type == "MSSQL") {
         $connectionInfo = array("Database" => $this->database, "UID" => $this->username, "PWD" => $this->password);
         $this->connection = sqlsrv_connect($this->address, $connectionInfo);
         if (!$this->connection) {
             $errorString = "";
             if (($errors = sqlsrv_errors()) != null) {
                 foreach ($errors as $error) {
                     $errorString .= PHP_EOL . "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" . PHP_EOL;
                     $errorString .= "SQLSTATE: " . $error['SQLSTATE'] . PHP_EOL;
                     $errorString .= "code: " . $error['code'] . PHP_EOL;
                     $errorString .= "message: " . $error['message'] . PHP_EOL;
                 }
             }
             $this->lastErrorMessage = "Error: Unable to connect to SQL Server." . PHP_EOL . "Debugging error: " . $errorString . PHP_EOL;
             $this->lastError = $errorString;
             return false;
         }
     }
     return $this->connection;
 }
Example #11
0
 public function connect($url, $username, $password)
 {
     if (!function_exists('sqlsrv_connect')) {
         return false;
     }
     $tmp = parse_url($url);
     if (!array_key_exists('scheme', $tmp) || $tmp['scheme'] != 'sqlserver') {
         throw new DataAccessException("데이터베이스 스키마가 드라이버와 일치하지 않습니다.");
     }
     $arrTmp = explode(';', $tmp['host']);
     $arrOptions = array();
     foreach ($arrTmp as $option) {
         if (trim($option) == '') {
             continue;
         }
         if (substr_count($option, '=') > 0) {
             list($k, $v) = explode('=', $option, 2);
             $arrOptions[$k] = $v;
         } else {
             $arrOptions['host'] = $option;
         }
     }
     if (!array_key_exists('DatabaseName', $arrOptions)) {
         throw new DataAccessException("데이터베이스 명이 누락되었습니다.");
     }
     $characterSet = !array_key_exists('CharacterSet', $arrOptions) ? 'UTF-8' : $arrOptions['CharacterSet'];
     $this->_host = $arrOptions['host'];
     try {
         $this->_conn = sqlsrv_connect($this->_host, array("Database" => $arrOptions['DatabaseName'], "UID" => $username, "PWD" => $password, "CharacterSet" => $characterSet));
     } catch (Exception $ex) {
         throw $ex;
     }
     $this->_connected = $this->_conn ? true : false;
     return $this->_connected;
 }
Example #12
0
function dbcall()
{
    session_start();
    $seubid = (string) session_id();
    $server = "bamsql2";
    $options = array("UID" => "genes", "PWD" => "Genes12", "Database" => "genes");
    $conn = sqlsrv_connect($server, $options);
    if ($conn === false) {
        die("<pre>" . print_r(sqlsrv_errors(), true));
    }
    $rno = $_POST['Rnumber'];
    $name = $_POST['name'];
    $email = $_POST['email'];
    $gender = $_POST['gender'];
    $sql = "insert INTO dbo.contactinfo values('{$rno}','{$name}','{$email}','{$gender}')";
    $query = sqlsrv_query($conn, $sql);
    if ($query === false) {
        exit("<pre>" . print_r(sqlsrv_errors(), true));
    }
    #while ($row = sqlsrv_fetch_array($query))
    # {  echo "<p>Hello, $row[ascore]!</p>";
    #}
    sqlsrv_free_stmt($query);
    sqlsrv_close($conn);
}
 public function connect($parameters, $selectDB = false)
 {
     // Disable default warnings as errors behaviour for sqlsrv to keep it in line with mssql functions
     if (ini_get('sqlsrv.WarningsReturnAsErrors')) {
         ini_set('sqlsrv.WarningsReturnAsErrors', 'Off');
     }
     $charset = isset($parameters['charset']) ? $parameters : 'UTF-8';
     $multiResultSets = isset($parameters['multipleactiveresultsets']) ? $parameters['multipleactiveresultsets'] : true;
     $options = array('CharacterSet' => $charset, 'MultipleActiveResultSets' => $multiResultSets);
     if (!(defined('MSSQL_USE_WINDOWS_AUTHENTICATION') && MSSQL_USE_WINDOWS_AUTHENTICATION == true) && empty($parameters['windowsauthentication'])) {
         $options['UID'] = $parameters['username'];
         $options['PWD'] = $parameters['password'];
     }
     // Required by MS Azure database
     if ($selectDB && !empty($parameters['database'])) {
         $options['Database'] = $parameters['database'];
     }
     $this->dbConn = sqlsrv_connect($parameters['server'], $options);
     if (empty($this->dbConn)) {
         $this->databaseError("Couldn't connect to SQL Server database");
     } elseif ($selectDB && !empty($parameters['database'])) {
         // Check selected database (Azure)
         $this->selectedDatabase = $parameters['database'];
     }
 }
 public function connect()
 {
     if ($this->_connection) {
         return;
     }
     // Extract the connection parameters, adding required variabels
     $mssql_config = $this->_config['connection'] + array('Database' => '', 'Server' => '', 'UID' => '', 'PWD' => '', 'ConnectionPooling' => FALSE, 'CharacterSet' => 'UTF-8');
     // Extract the Server name
     $server = $mssql_config['Server'];
     // Prevent this information from showing up in traces
     unset($mssql_config['Server'], $this->_config['connection']['UID'], $this->_config['connection']['PWD']);
     // If any illegal properties is in $mssql_config, sqlsrv_connect won't connect
     unset($mssql_config['hostname'], $mssql_config['database'], $mssql_config['username'], $mssql_config['password'], $mssql_config['persistent']);
     try {
         // Create a connection
         $this->_connection = sqlsrv_connect($server, $mssql_config);
         $errors = sqlsrv_errors(SQLSRV_ERR_ALL);
         if ($this->_connection === FALSE) {
             throw new Database_Sqlsrv_Exception(':error, :sqlstate', array(':error' => $errors[0]['message'], ':sqlstate' => $errors[0]['SQLSTATE']), $errors[0]['code']);
         }
     } catch (ErrorException $e) {
         $errors = sqlsrv_errors(SQLSRV_ERR_ALL);
         throw new Database_Sqlsrv_Exception(':error, :sqlstate', array(':error' => $errors[0]['message'], ':sqlstate' => $errors[0]['SQLSTATE']), $errors[0]['code']);
     }
     // \xFF is a better delimiter, but the PHP driver uses underscore
     $this->_connection_id = sha1($server . '_' . $mssql_config['UID'] . '_' . $mssql_config['PWD']);
 }
Example #15
0
 function OpenConnection()
 {
     global $mysqlAuthentication;
     global $sqlserverAuthentication;
     $host = null;
     $options = null;
     if (isset($mysqlAuthentication)) {
         $host = $mysqlAuthentication["host"];
         $options = $mysqlAuthentication;
     }
     if ($this->databaseType == 'mySql' || $this->databaseType == 'both') {
         $this->mysqlConnection = @mysql_connect($host, $options["username"], $options["password"]);
     }
     if (isset($this->mysqlConnection)) {
         @mysql_set_charset("utf8");
         @mysql_select_db($options["database"], $this->mysqlConnection);
     }
     if (isset($sqlserverAuthentication)) {
         $host = $sqlserverAuthentication["host"];
         $options = array("Database" => $sqlserverAuthentication["database"], "CharacterSet" => "UTF-8", "UID" => $sqlserverAuthentication["username"], "PWD" => $sqlserverAuthentication["password"]);
     }
     if ($this->databaseType == 'sqlServer' || $this->databaseType == 'both') {
         $this->sqlserverConnection = sqlsrv_connect($host, $options);
     }
 }
Example #16
0
 protected function connect()
 {
     if ($this->lnk === null) {
         $options = $this->settings->options;
         $options['Database'] = $this->settings->database;
         $options['ReturnDatesAsStrings'] = true;
         if ($this->settings->username) {
             $options['UID'] = $this->settings->username;
         }
         if ($this->settings->password) {
             $options['PWD'] = $this->settings->password;
         }
         if ($this->settings->charset) {
             //$options["CharacterSet"] = strtoupper($this->settings->charset);
         }
         $server = $this->settings->servername;
         if (isset($this->settings->serverport) && $this->settings->serverport) {
             $server .= ', ' . $this->settings->serverport;
         }
         $this->lnk = @sqlsrv_connect($server, $options);
         if ($this->lnk === false) {
             throw new DatabaseException('Connect error');
         }
     }
 }
Example #17
0
function SaveLecturerMarks($marks)
{
    $status = array();
    include_once 'db_Connection.php';
    $conn = sqlsrv_connect($serverName, $connectionInfo);
    if ($conn) {
        $login = "******";
        $subjectid = 0;
        $subjtype = 0;
        $lectid = 0;
        $qid = 0;
        $mark = 0;
        $ldescription = "0";
        $sqlstr = " insert into [dbo].[MarkLecturer] ([Login],[subjid],[subjtype],[lectid],[qid],[mark],[ldescription]) " . " values (?,?,?,?,?,?,?) ";
        $params = array(&$login, &$subjectid, &$subjtype, &$lectid, &$qid, &$mark, &$ldescription);
        $stmt = sqlsrv_prepare($conn, $sqlstr, $params);
        if ($stmt) {
            foreach ($marks as &$data) {
                $login = $data->login;
                $subjectid = $data->subjectid;
                $subjtype = $data->subjtype;
                $lectid = $data->lectid;
                $qid = $data->qid;
                $mark = $data->mark;
                $ldescription = $data->description;
                if (!sqlsrv_execute($stmt)) {
                    array_push($status, "not inserted-L" . $login . "-S" . $subjectid . "-T" . $subjtype . "-L" . $lectid . "-Q" . $qid);
                }
            }
        }
        sqlsrv_close($conn);
    }
    return $status;
}
Example #18
0
 /**
  * @param String $serverName Target server name or host.
  * @param Array  $conninfo   Associative array containing the db connection required parameters.
  *                           Expected keys: UID, PWD, Database
  */
 public function __construct($serverName, $connInfo)
 {
     $this->dbh = sqlsrv_connect($serverName, $connInfo);
     if ($this->dbh === false) {
         return false;
     }
 }
Example #19
0
 public function __construct($serverName, $connectionOptions)
 {
     $this->conn = sqlsrv_connect($serverName, $connectionOptions);
     if (!$this->conn) {
         throw SQLSrvException::fromSqlSrvErrors();
     }
     $this->lastInsertId = new LastInsertId();
 }
 /**
  * Constructs a new instance of NorthWindQueryProvider
  * 
  */
 public function __construct()
 {
     $this->_connectionHandle = sqlsrv_connect(SERVER, array("Database" => DATABASE));
     if ($this->_connectionHandle) {
     } else {
         die(print_r(sqlsrv_errors(), true));
     }
 }
function sqlsrvConnect()
{
    // Functionalized it for later OOB
    $serverName = "qserv\\sql2008";
    //serverName\instanceName
    $connectionInfo = array("Database" => "WYSAC_Website", "UID" => "wysacweb_app", "PWD" => "1p7kS5kiRp(dj33q");
    return sqlsrv_connect($serverName, $connectionInfo);
}
Example #22
0
 private function connect()
 {
     $this->connection = sqlsrv_connect($this->hostname, $this->connInfo);
     if (!$this->connection) {
         //trigger_error("Incorrect Connection Parameter",E_USER_WARNING);
         self::$error = true;
     }
 }
Example #23
0
 /**
  * Criar conexão com servidor SQL
  *
  * @return void
  */
 public function __construct()
 {
     $info = array('UID' => $this->user, 'PWD' => $this->password, 'Database' => $this->db, 'CharacterSet' => 'UTF-8');
     $this->conn = sqlsrv_connect($this->host, $info);
     if ($this->conn === false) {
         die(print_r(sqlsrv_errors(), true));
     }
 }
Example #24
0
 /**
  * @covers Zend\Db\Adapter\Driver\Sqlsrv\Connection::setResource
  */
 public function testSetResource()
 {
     $resource = sqlsrv_connect($this->variables['hostname'], array('UID' => $this->variables['username'], 'PWD' => $this->variables['password']));
     $connection = new Connection(array());
     $this->assertSame($connection, $connection->setResource($resource));
     $connection->disconnect();
     unset($connection);
     unset($resource);
 }
Example #25
0
 /**
  * Open a connection to db
  */
 public function connect()
 {
     $connectionInfo = array("Database" => $this->dbname, "PWD" => $this->pwd, "UID" => $this->user);
     $this->conn = sqlsrv_connect($this->host, $connectionInfo);
     if (!$this->conn) {
         triggerErrorMSSQL();
     }
     return $this->conn;
 }
 /**
  * Constructor
  */
 public function __construct()
 {
     $connectionInfo = array("UID" => DBSettings::$dbUser, "PWD" => DBSettings::$dbPass, "Database" => DBSettings::$database, "ReturnDatesAsStrings" => true);
     $this->_connection = sqlsrv_connect(DBSettings::$Server, $connectionInfo);
     // Creates and opens a connection.
     if ($this->_connection == null) {
         trigger_error('Failed to connect to SQL: ' . dbGetErrorMsg());
     }
 }
 private function _connect()
 {
     $param = array('Database' => $this->databasename, 'UID' => $this->username, 'PWD' => $this->password, "CharacterSet" => $this->code);
     $result = sqlsrv_connect($this->servername, $param);
     if (is_resource($result)) {
         $this->_db = $result;
     }
     return $result;
 }
 function db_connect($pooling = false)
 {
     $character_set = 0 === strcasecmp('utf8', $this->char_set) ? 'UTF-8' : $this->char_set;
     $connection = array('UID' => empty($this->username) ? '' : $this->username, 'PWD' => empty($this->password) ? '' : $this->password, 'Database' => $this->database, 'ConnectionPooling' => $pooling ? 1 : 0, 'CharacterSet' => $character_set, 'ReturnDatesAsStrings' => 1);
     if (empty($connection['UID']) && empty($connection['PWD'])) {
         unset($connection['UID'], $connection['PWD']);
     }
     return sqlsrv_connect($this->hostname, $connection);
 }
Example #29
0
 public function connect()
 {
     if ($connection = sqlsrv_connect($this->host, ['UID' => $this->user, 'PWD' => $this->pass, 'Database' => $this->name])) {
         $this->connection = $connection;
     } else {
         trigger_error('Could not connect to Database');
         exit;
     }
 }
Example #30
-1
 /**
  * Connect to the database.
  *
  * @throws     <b>AgaviDatabaseException</b> If a connection could not be 
  *                                           created.
  *
  * @author     David Zülke <*****@*****.**>
  * @since      1.0.4
  */
 protected function connect()
 {
     $serverName = $this->getParameter('server_name');
     if ($serverName == null) {
         // missing required server_name parameter
         $error = 'Database configuration is missing "server_name" parameter';
         throw new AgaviDatabaseException($error);
     }
     if ($this->hasParameter('settings')) {
         foreach ((array) $this->getParameter('settings') as $key => $value) {
             if (!sqlsrv_configure($key, is_string($value) && strpos($value, 'SQLSRV_') === 0 && defined($value) ? constant($value) : (is_numeric($value) ? (int) $value : $value))) {
                 throw new AgaviDatabaseException(sprintf('Unsupported key or value for setting "%s".', $key));
             }
         }
     }
     $connectionInfo = $this->getParameter('connection_info');
     foreach ($connectionInfo as &$value) {
         $value = is_string($value) && strpos($value, 'SQLSRV_') === 0 && defined($value) ? constant($value) : (is_numeric($value) ? (int) $value : $value);
     }
     $this->connection = sqlsrv_connect($serverName, $connectionInfo);
     if (!$this->connection) {
         $this->connection = null;
         throw new AgaviDatabaseException(sprintf("%s\n\n%s", sprintf('Could not open database connection "%s".', $this->getName()), implode("\n", $this->getErrors())));
     }
     $this->resource =& $this->connection;
     foreach ((array) $this->getParameter('init_queries') as $query) {
         sqlsrv_query($this->connection, $query);
     }
 }