Skip to content

Conversation

@NattyNarwhal
Copy link
Member

@NattyNarwhal NattyNarwhal commented Jan 22, 2026

The persistent connection may be in a wedged or otherwise undesirable state that the connection liveness check has failed to deal with. (For instance, the ODBC connection dead attribute that PDO_ODBC uses to check isn't perfectly handled by all drivers, or if a persistent connection has bad persistent state, it's easier to just reconnect if so.) If so, provide userland code a way to get rid of a persistent connection and create a new one in its place.

This is prompted by the discussion in GH-15749 and GH-19933. I think adding a notion of disconnected PDO objects is probably unwise, so this provides an alternative that requires very minimal changes in PDO. I'm not entirely pleased with this approach, but perhaps there is a better one. I don't intend to get this merged, without a discussion anyways - I'll bring that up on internals.

The persistent connection may be in a wedged or otherwise undesirable
state that the connection liveness check has failed to deal with. If
so, provide userland code a way to get rid of a persistent connection
and create a new one in its place.

I'm not entirely pleased with this approach, but perhaps there is a
better one.
@NattyNarwhal
Copy link
Member Author

Example:

<?php

$dsn = "";
$username = "";
$password = "";
$attrs = [PDO::ATTR_PERSISTENT => true];
if (isset($_GET["new"])) {
	$attrs[PDO::ATTR_PERSISTENT_NEW_CONNECTION] = true;
}
$odbc = new PDO($dsn, $username, $password, $attrs);

// example database specific method to see if we're connected to the same database process
$stmt = $odbc->prepare("select JOB_NAME from table(QSYS2.ACTIVE_JOB_INFO(JOB_NAME_FILTER => '*'))");
$stmt->execute();
$rows = $stmt->fetchAll();

echo "<pre>";
var_dump($rows);
echo "</pre>";
?>
<form action="/new.php">
	<input type="checkbox" name="new" id="new" />
	<label for="new">New job</label>
	<input type="submit" />
</form>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant