[php-src] Issue #12767: [pdo_odbc] Unable to turn on autocommit mode with `setAttribute`

From: Date: Fri, 24 Nov 2023 12:57:37 +0000
Subject: [php-src] Issue #12767: [pdo_odbc] Unable to turn on autocommit mode with `setAttribute`
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-245883@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/12767 Author: SakiTakamachi ### Description The following code: ```php <?php $dsn = "/* your dsn */"; $user = "/* your user */"; $pass = "/* your pass */"; $db = new PDO($dsn, $user, $pass); $db->exec("CREATE TABLE test (id INT, name VARCHAR(255))"); unset($db); $db = new PDO($dsn, $user, $pass, [ PDO::ATTR_AUTOCOMMIT => 0, ]); $db->setAttribute(PDO::ATTR_AUTOCOMMIT, 1); $db->query("INSERT INTO test (id, name) VALUES (1, 'test')"); unset($db); $db = new PDO($dsn, $user, $pass); $r = $db->query("SELECT * FROM test"); var_dump($r->fetchAll(PDO::FETCH_ASSOC)); ``` Resulted in this output: ``` array(0) { } ``` But I expected this output instead: ``` array(1) { [0]=> array(2) { ["id"]=> string(1) "1" ["name"]=> string(4) "test" } } ``` I noticed the bug while reading the C source code, so I already know the cause. This is because when you change the attribute value after the constructor, nothing is done. The fix may be ready by the end of 8.1's bug fixes. ### PHP Version PHP8.1 ~ master ### Operating System _No response_

« previous php.bugs (#245883) next »