Browse Source

added dblib option to sqlsrv connector class /sam fitz (abigwonderful)

simple conditional added to look for dsn type. if set and is dblib,
syntax for PDO connection adjusted slightly to allow for mac connection
to mssql server (utilizing freetds)
Samuel Fitz 12 years ago
parent
commit
db351fedf0
1 changed files with 10 additions and 2 deletions
  1. 10 2
      laravel/database/connectors/sqlserver.php

+ 10 - 2
laravel/database/connectors/sqlserver.php

@@ -28,8 +28,16 @@ class SQLServer extends Connector {
 		// also be used to connect to Azure SQL Server databases. The port is defined
 		// also be used to connect to Azure SQL Server databases. The port is defined
 		// directly after the server name, so we'll create that first.
 		// directly after the server name, so we'll create that first.
 		$port = (isset($port)) ? ','.$port : '';
 		$port = (isset($port)) ? ','.$port : '';
-
-		$dsn = "sqlsrv:Server={$host}{$port};Database={$database}";
+		
+		//check for dblib for mac users connecting to mssql (utilizes freetds)
+		if (!empty($dsn_type) and $dsn_type == 'dblib')
+		{
+			$dsn = "dblib:host={$host}{$port};dbname={$database}";
+		}
+		else
+		{
+			$dsn = "sqlsrv:Server={$host}{$port};Database={$database}";
+		}
 
 
 		return new PDO($dsn, $username, $password, $this->options($config));
 		return new PDO($dsn, $username, $password, $this->options($config));
 	}
 	}