microsoft / msphpsql

Microsoft Drivers for PHP for SQL Server
MIT License
1.8k stars 374 forks source link

PHP 8.3.9 / 5.12.0 / 18.03.0003 SQLSTATE[IMSSP]: An invalid attribute was designated on the PDO object #1518

Closed kahalabrands closed 2 months ago

kahalabrands commented 3 months ago

PHP version
PHP Version 8.3.9

PHP SQLSRV or PDO_SQLSRV version PDO_SQLSRV = 5.12.0

Microsoft ODBC Driver version
18.03.0003

SQL Server version
14.00.2052

Client operating system
Ubuntu

Table schema
N/A

Problem description
Getting the following error: SQLSTATE[IMSSP]: An invalid attribute was designated on the PDO object.

Expected behavior and actual behavior
N/A

Repro code or steps to reproduce Try to connect using PHP pdo connection with versions mentioned above.

v-makouz commented 3 months ago

Do you have a repro script?

Looking at the code, it looks like the following attributes are not supported by PDO:

ATTR_FETCH_TABLE_NAMES
ATTR_FETCH_CATALOG_NAMES
ATTR_PREFETCH
ATTR_MAX_COLUMN_LEN
ATTR_CURSOR_NAME
ATTR_AUTOCOMMIT
ATTR_PERSISTENT
ATTR_TIMEOUT
kahalabrands commented 3 months ago

Ok so what do I do then. I can't remove them I don't think. I set your suggested attributes to false and the following error returns. Seems like they need to be removed completely. I set them as false as a group and individually and all tests returned the same error.

Fatal error: Uncaught PDOException: SQLSTATE[IMSSP]: An unsupported attribute was designated on the PDO object. in /home/devmarketing/shared/Medoo.php:499 Stack trace: #0 /home/devmarketing/public_html/assets/includes/medoo_test.php(21): Medoo\Medoo->__construct(Array) #1 {main} thrown in /home/devmarketing/shared/Medoo.php on line 499

v-makouz commented 3 months ago

How are you calling the PHP driver? When it's invoked it looks something like: $conn = new PDO($connOptions, $uid, $pwd, array(SOME_ATTRIBUTE => VALUE, OTHER_ATTRIBUTE => VALUE2)); so as long as those attributes are not specified in the list, this error shouldn't happen.

kahalabrands commented 3 months ago

Thanks for the help on this. Come to find out there was no issues at all on this. Sorry about the 911. I am migrating to a brand new server that has brand new everything. The way I was debugging was to just look at error messages in the code. I didn't actually try to execute the query to see if I was getting data back just the pdo connection info. The connection info reports that invalid attribute error but the query actually executes and returns data. So I think we are good. I have had to try getting this installed on three different new servers and that message was popular with older versions of php not 8.3+ so I thought I was running into the same issue....a bit confusing. I think we are good. Thanks again.