1: <?php namespace Laravel\Database\Connectors; use PDO;
2:
3: class SQLServer extends Connector {
4:
5: 6: 7: 8: 9:
10: protected $options = array(
11: PDO::ATTR_CASE => PDO::CASE_LOWER,
12: PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
13: PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL,
14: PDO::ATTR_STRINGIFY_FETCHES => false,
15: );
16:
17: 18: 19: 20: 21: 22:
23: public function connect($config)
24: {
25: extract($config);
26:
27:
28:
29:
30: $port = (isset($port)) ? ','.$port : '';
31:
32:
33: if (in_array('dblib',PDO::getAvailableDrivers()))
34: {
35: $dsn = "dblib:host={$host}{$port};dbname={$database}";
36: }
37: else
38: {
39: $dsn = "sqlsrv:Server={$host}{$port};Database={$database}";
40: }
41:
42: return new PDO($dsn, $username, $password, $this->options($config));
43: }
44:
45: }