Error in laravel application with sql server in windows

0

I have configured the xampp v3.2.2 with sql srv, I have a laravel 5.5 application configured to connect to the sql server as follows:

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:SFla+HfV2OBTy/KYCrSZeBbwGWMUfZBKrnKwNzJrfQU=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://app.develop

DB_CONNECTION=sqlsrv
DB_HOST=IP
DB_PORT=1433
DB_DATABASE=BD
DB_USERNAME=sa
DB_PASSWORD=pass
DB_CHARSET=utf8
DB_COLLATION=utf8_unicode_ci

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
...

When I start the application I ask for a query and I get the following error:

 Illuminate \ Database \ QueryException (IMSSP)
SQLSTATE[IMSSP]: An unsupported attribute was designated on the PDO object. (SQL: select top 1 * from [users] where [email] = email)

The same application works without problem on Ubuntu 17 and 18 ...

I have downloaded the sql server drivers provided by microsoft and included the following lines in the php.ini extensions

extension=php_sqlsrv_72_ts_x86.dll
extension=php_pdo_sqlsrv_72_ts_x86.dll

and the libraries in the php ext folder ....

    
asked by Yoedusvany Hdez 21.05.2018 в 16:01
source

1 answer

1

I answer, I found the root of the problem, you just have to uncomment an attribute in the laravel connection in the file approot / config / database.php

In this are the connections for the BD where the system communicated, for sql server had the following definition:

'sqlsrv' => [
            'driver' => 'sqlsrv',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'options' => [
                PDO::ATTR_TIMEOUT => 300000,
            ],
        ],

I removed the options attribute, staying as follows

 'sqlsrv' => [
            'driver' => 'sqlsrv',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            /*'options' => [
                PDO::ATTR_TIMEOUT => 300000,
            ],*/
        ],

and ready the authentic system, and shows the data ....

    
answered by 21.05.2018 в 17:00