Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDO::getAttribute() does not support PDO::ATTR_TIMEOUT #2034

Open
shyim opened this issue Nov 14, 2022 · 2 comments
Open

PDO::getAttribute() does not support PDO::ATTR_TIMEOUT #2034

shyim opened this issue Nov 14, 2022 · 2 comments
Labels
bug Documentation contains incorrect information Extension: pdo All PDO related doc issues

Comments

@shyim
Copy link
Contributor

shyim commented Nov 14, 2022

Description

The following code:

<?php

$dsn = 'mysql:dbname=testdb;host=127.0.0.1';
$user = 'dbuser';
$password = 'dbpass';

$pdo = new PDO($dsn, $user, $password);
$pdo->setAttribute(\PDO::ATTR_TIMEOUT, 5);

var_dump($pdo->getAttribute(\PDO::ATTR_TIMEOUT));

It seems like not covered by https://github.com/php/php-src/blob/master/ext/pdo_mysql/mysql_driver.c#L490

Resulted in this output:

Fatal error: Uncaught PDOException: SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute

But I expected this output instead:

int(5)

PHP Version

PH P 8.1.12

Operating System

macOS Ventura 13.1 Beta 2

@shyim shyim added bug Documentation contains incorrect information Status: Needs Triage labels Nov 14, 2022
@shyim shyim changed the title PDO MySQL Can set ATTR_TIMEOUT but don't able to get it PDO MySQL Can get ATTR_TIMEOUT but able to set it Nov 14, 2022
@cmb69
Copy link
Contributor

cmb69 commented Nov 14, 2022

As is, for PDO_MySQL this is a connection attribute, so setting it after the the PDO instance has been constructed, won't change anything. Still, it should be possible to retrieve the timeout, I guess.

@cmb69
Copy link
Contributor

cmb69 commented Nov 30, 2022

Well, apparently none of the other bundled PDO drivers supports getting the value of PDO::ATTR_TIMEOUT either, so I think we should leave it as this, but document it (currently, PDO::ATTR_TIMEOUT is explicitly listed as $attribute for PDO::getAttribute()).

@cmb69 cmb69 changed the title PDO MySQL Can get ATTR_TIMEOUT but able to set it PDO::getAttribute() does not support PDO::ATTR_TIMEOUT Nov 30, 2022
@cmb69 cmb69 transferred this issue from php/php-src Nov 30, 2022
@Girgias Girgias added the Extension: pdo All PDO related doc issues label Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Documentation contains incorrect information Extension: pdo All PDO related doc issues
Projects
None yet
Development

No branches or pull requests

3 participants