msphpsql icon indicating copy to clipboard operation
msphpsql copied to clipboard

ATTR_ERRMODE exception is not supported

Open Jamesking56 opened this issue 9 years ago • 16 comments

Hello,

Converting a running Laravel app on Windows to run under PHP 7 + Sql Server driver for Linux.

When PDO::ATTR_ERRMODE is set to PDO::ERRMODE_EXCEPTION I get this error:

SQLSTATE[IMSSP]: An unsupported attribute was designated on the PDO object.

This is supported in PDO_SQLSRV for Windows but not as it seems for linux....

I'm running CentOS 7, PHP 7.0.14, Apache 2.4.6

Jamesking56 avatar Jan 10 '17 10:01 Jamesking56

@Jamesking56 Could you provide a repro script for this issue?

david-puglielli avatar Jan 10 '17 19:01 david-puglielli

I cannot confirm this issue. I am using version 4.0.8 on Ubuntu 16.04 and it works perfectly.

deeky666 avatar Feb 09 '17 14:02 deeky666

Hard to produce a repro script because it's a private codebase.

I can however tell you its Laravel 4.2 and runs in Windows Server 2012 R2 at present with SQL Server 2014 on Windows.

Jamesking56 avatar Feb 09 '17 16:02 Jamesking56

This is a peculiar error message to get, as it is only supposed to show up if you are trying to set a PDO attribute that we do not support, such as prefetch or autocommit. It is only called in these two locations: https://github.com/Microsoft/msphpsql/blob/master/source/pdo_sqlsrv/pdo_dbh.cpp#L939 https://github.com/Microsoft/msphpsql/blob/master/source/pdo_sqlsrv/pdo_dbh.cpp#L1006

Please take a look and make sure that you not setting one of the attributes that will trigger the error in your script.

david-puglielli avatar Feb 11 '17 00:02 david-puglielli

Hi @Jamesking56 do you have any update about this problem?

yitam avatar Feb 20 '17 17:02 yitam

@Jamesking56 Closing due to inactivity and failure of being able to repro this on our end. Feel free to reopen if you still need help.

meet-bhagdev avatar Feb 23 '17 00:02 meet-bhagdev

i just easily confirmed it...running Win10 xampp with php 7.2.

dsn = sqlsvr

$this->_conn = new parent($dsn, $this->user, $this->pass,[
			PDO::ATTR_PERSISTENT => true,
			PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);

PHP Fatal error: Uncaught PDOException: SQLSTATE[IMSSP]: An unsupported attribute was designated on the PDO object. in /C:/xampp72/htdocs/ats/app/model/PdoConfig.php on line 48

menriquez avatar Apr 18 '19 20:04 menriquez

Just so you know, @menriquez, PDO::ATTR_PERSISTENT is indeed not supported. However, the problem raised in this issue was about PDO::ATTR_ERRMODE.

yitam avatar Apr 18 '19 20:04 yitam

Hello,

Converting a running Laravel app on Windows to run under PHP 7 + Sql Server driver for Linux.

When PDO::ATTR_ERRMODE is set to PDO::ERRMODE_EXCEPTION I get this error:

SQLSTATE[IMSSP]: An unsupported attribute was designated on the PDO object.

This is supported in PDO_SQLSRV for Windows but not as it seems for linux....

I'm running CentOS 7, PHP 7.0.14, Apache 2.4.6

for me

My project is using iis php8.2.9 lavarel 10 mssql. It is had this issue. I use xdebug for look at the process. I find \vendor\laravel\framework\src\Illuminate\Database\Connectors\SqlServerConnector.php line 19 PDO::ATTR_STRINGIFY_FETCHES => false. It will appear error and cross off it . it is fix.

My all day.... QQ

gavin1420 avatar Aug 10 '23 09:08 gavin1420

Hello, Converting a running Laravel app on Windows to run under PHP 7 + Sql Server driver for Linux. When PDO::ATTR_ERRMODE is set to PDO::ERRMODE_EXCEPTION I get this error: SQLSTATE[IMSSP]: An unsupported attribute was designated on the PDO object. This is supported in PDO_SQLSRV for Windows but not as it seems for linux.... I'm running CentOS 7, PHP 7.0.14, Apache 2.4.6

for me

My project is using iis php8.2.9 lavarel 10 mssql. It is had this issue. I use xdebug for look at the process. I find \vendor\laravel\framework\src\Illuminate\Database\Connectors\SqlServerConnector.php line 19 PDO::ATTR_STRINGIFY_FETCHES => false. It will appear error and cross off it . it is fix.

My all day.... QQ

Thanks, I commented this line and problem solved :)

Tahernejad avatar Aug 12 '23 01:08 Tahernejad

Hello, Converting a running Laravel app on Windows to run under PHP 7 + Sql Server driver for Linux. When PDO::ATTR_ERRMODE is set to PDO::ERRMODE_EXCEPTION I get this error: SQLSTATE[IMSSP]: An unsupported attribute was designated on the PDO object. This is supported in PDO_SQLSRV for Windows but not as it seems for linux.... I'm running CentOS 7, PHP 7.0.14, Apache 2.4.6

for me

My project is using iis php8.2.9 lavarel 10 mssql. It is had this issue. I use xdebug for look at the process. I find \vendor\laravel\framework\src\Illuminate\Database\Connectors\SqlServerConnector.php line 19 PDO::ATTR_STRINGIFY_FETCHES => false. It will appear error and cross off it . it is fix.

My all day.... QQ

yes this fixed the issue but we can't change vendor directory so why this issue accuored and how to fixed it permanently !!

umehmood124 avatar Aug 16 '23 10:08 umehmood124

Hello, Converting a running Laravel app on Windows to run under PHP 7 + Sql Server driver for Linux. When PDO::ATTR_ERRMODE is set to PDO::ERRMODE_EXCEPTION I get this error: SQLSTATE[IMSSP]: An unsupported attribute was designated on the PDO object. This is supported in PDO_SQLSRV for Windows but not as it seems for linux.... I'm running CentOS 7, PHP 7.0.14, Apache 2.4.6

for me My project is using iis php8.2.9 lavarel 10 mssql. It is had this issue. I use xdebug for look at the process. I find \vendor\laravel\framework\src\Illuminate\Database\Connectors\SqlServerConnector.php line 19 PDO::ATTR_STRINGIFY_FETCHES => false. It will appear error and cross off it . it is fix. My all day.... QQ

yes this fixed the issue but we can't change vendor directory so why this issue accuored and how to fixed it permanently !!

@umehmood124 you can do this. I've tested that solution myself, and it worked like a charm.

EDIT: I don't know if the option PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE => true from the proposed solution is actually needed or not. It is not included in the base SqlServerConnector, so I assume it isn't? In case anyone knows if there's added value to adding it, it'd be good to know.

gianfranco-rocco avatar Aug 18 '23 14:08 gianfranco-rocco

Hello, Converting a running Laravel app on Windows to run under PHP 7 + Sql Server driver for Linux. When PDO::ATTR_ERRMODE is set to PDO::ERRMODE_EXCEPTION I get this error: SQLSTATE[IMSSP]: An unsupported attribute was designated on the PDO object. This is supported in PDO_SQLSRV for Windows but not as it seems for linux.... I'm running CentOS 7, PHP 7.0.14, Apache 2.4.6

for me My project is using iis php8.2.9 lavarel 10 mssql. It is had this issue. I use xdebug for look at the process. I find \vendor\laravel\framework\src\Illuminate\Database\Connectors\SqlServerConnector.php line 19 PDO::ATTR_STRINGIFY_FETCHES => false. It will appear error and cross off it . it is fix. My all day.... QQ

yes this fixed the issue but we can't change vendor directory so why this issue accuored and how to fixed it permanently !!

@umehmood124 you can do this. I've tested that solution myself, and it worked like a charm.

Thanks That Worked !!

umehmood124 avatar Aug 20 '23 10:08 umehmood124

Hello, Converting a running Laravel app on Windows to run under PHP 7 + Sql Server driver for Linux. When PDO::ATTR_ERRMODE is set to PDO::ERRMODE_EXCEPTION I get this error: SQLSTATE[IMSSP]: An unsupported attribute was designated on the PDO object. This is supported in PDO_SQLSRV for Windows but not as it seems for linux.... I'm running CentOS 7, PHP 7.0.14, Apache 2.4.6

for me My project is using iis php8.2.9 lavarel 10 mssql. It is had this issue. I use xdebug for look at the process. I find \vendor\laravel\framework\src\Illuminate\Database\Connectors\SqlServerConnector.php line 19 PDO::ATTR_STRINGIFY_FETCHES => false. It will appear error and cross off it . it is fix. My all day.... QQ

yes this fixed the issue but we can't change vendor directory so why this issue accuored and how to fixed it permanently !!

Thanks its worked for me!!!

jhenriquez90 avatar Aug 21 '23 20:08 jhenriquez90

Hello, Converting a running Laravel app on Windows to run under PHP 7 + Sql Server driver for Linux. When PDO::ATTR_ERRMODE is set to PDO::ERRMODE_EXCEPTION I get this error: SQLSTATE[IMSSP]: An unsupported attribute was designated on the PDO object. This is supported in PDO_SQLSRV for Windows but not as it seems for linux.... I'm running CentOS 7, PHP 7.0.14, Apache 2.4.6

for me

My project is using iis php8.2.9 lavarel 10 mssql. It is had this issue. I use xdebug for look at the process. I find \vendor\laravel\framework\src\Illuminate\Database\Connectors\SqlServerConnector.php line 19 PDO::ATTR_STRINGIFY_FETCHES => false. It will appear error and cross off it . it is fix.

My all day.... QQ

Thanks bro. You saved me from a catastrophe

eduxsolano avatar Aug 22 '23 09:08 eduxsolano

Instead of editing the vendor file, i created a custom connector php 8.1 and Laravel 10

namespace App\Database\Connectors;

use Illuminate\Database\Connectors\SqlServerConnector as BaseSqlServerConnector;

class SqlServerConnector extends BaseSqlServerConnector
{
    public function createConnection($dsn, array $config, array $options)
    {
        // Remove the PDO::ATTR_STRINGIFY_FETCHES option
        unset($options[\PDO::ATTR_STRINGIFY_FETCHES]);

        return parent::createConnection($dsn, $config, $options);
    }
}

richardksizemore avatar Aug 25 '23 14:08 richardksizemore