ATTR_ERRMODE exception is not supported
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 Could you provide a repro script for this issue?
I cannot confirm this issue. I am using version 4.0.8 on Ubuntu 16.04 and it works perfectly.
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.
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.
Hi @Jamesking56 do you have any update about this problem?
@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.
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
Just so you know, @menriquez, PDO::ATTR_PERSISTENT is indeed not supported.
However, the problem raised in this issue was about PDO::ATTR_ERRMODE.
Hello,
Converting a running Laravel app on Windows to run under PHP 7 + Sql Server driver for Linux.
When
PDO::ATTR_ERRMODEis set toPDO::ERRMODE_EXCEPTIONI 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
Hello, Converting a running Laravel app on Windows to run under PHP 7 + Sql Server driver for Linux. When
PDO::ATTR_ERRMODEis set toPDO::ERRMODE_EXCEPTIONI 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.6for 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 :)
Hello, Converting a running Laravel app on Windows to run under PHP 7 + Sql Server driver for Linux. When
PDO::ATTR_ERRMODEis set toPDO::ERRMODE_EXCEPTIONI 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.6for 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 !!
Hello, Converting a running Laravel app on Windows to run under PHP 7 + Sql Server driver for Linux. When
PDO::ATTR_ERRMODEis set toPDO::ERRMODE_EXCEPTIONI 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.6for 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.
Hello, Converting a running Laravel app on Windows to run under PHP 7 + Sql Server driver for Linux. When
PDO::ATTR_ERRMODEis set toPDO::ERRMODE_EXCEPTIONI 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.6for 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 !!
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!!!
Hello, Converting a running Laravel app on Windows to run under PHP 7 + Sql Server driver for Linux. When
PDO::ATTR_ERRMODEis set toPDO::ERRMODE_EXCEPTIONI 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.6for 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
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);
}
}