Skip to content

Commit 23151c9

Browse files
author
Matheus Bueno Bartkevicius
committed
Adding the possibility of use 'charset' in the library
1 parent db219f2 commit 23151c9

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/Database/Connector.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,18 @@
66

77
class Connector extends SqlServerConnector
88
{
9-
//
9+
public function connect(array $config)
10+
{
11+
$options = $this->getOptions($config);
12+
13+
$connection = $this->createConnection($this->getDsn($config), $config, $options);
14+
15+
if(array_key_exists('charset', $config) && $config['charset'] != '') {
16+
$connection->prepare("set char_convert '{$config['charset']}'")->execute();
17+
}
18+
19+
$this->configureIsolationLevel($connection, $config);
20+
21+
return $connection;
22+
}
1023
}

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected function defineEnvironment($app)
4848
'database' => env('DB_DATABASE', 'forge'),
4949
'username' => env('DB_USERNAME', 'forge'),
5050
'password' => env('DB_PASSWORD', ''),
51-
// 'charset' => 'utf8',
51+
'charset' => 'utf8',
5252
'prefix' => '',
5353
'prefix_indexes' => true,
5454
'options' => array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION)

0 commit comments

Comments
 (0)