php / php/doc-en

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

Open
#2,034 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Extension: pdo
Dominant language
XML
Stars
596
Forks
890
Avg merge
1d 15h
Merged PRs (30d)
55

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ext/pdo_mysql/mysql_driver.c around line 490 and reproduce the PHP 8.1.12 example using PDO::ATTR_TIMEOUT. Compare the observed and expected behavior, then determine whether a documentation change is needed in php/doc-en or whether the issue belongs in PHP's implementation tracker; done means the correct repository and change scope are established.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, php
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.