Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Added IbmDb2 db2_pclose to disconnect #333

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/Adapter/Driver/IbmDb2/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,28 @@ public function isConnected()
public function disconnect()
{
if ($this->resource) {
db2_close($this->resource);

// localize
$p = $this->connectionParameters;

// given a list of key names, test for existence in $p
$findParameterValue = function (array $names) use ($p) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make a new private method returning bool instead. Also, array_change_key_case() is probably a better approach, since nothing guarantees that mIxEDCasE won't be given as parameter.

foreach ($names as $name) {
if (isset($p[$name])) {
return $p[$name];
}
}

return;
};
$isPersistent = $findParameterValue(['persistent', 'PERSISTENT', 'Persistent']);

if ((bool) $isPersistent) {
db2_pclose($this->resource);
} else {
db2_close($this->resource);
}

$this->resource = null;
}

Expand Down