yajra / pdo-via-oci8

PHP PDO_OCI functions via OCI8 extension
Other
88 stars 61 forks source link

set oracle connection identifier #99

Closed Sevyls closed 2 years ago

Sevyls commented 2 years ago

Summary of problem or feature request

regarding https://github.com/yajra/laravel-oci8/issues/453

Add feature to set the connection identifier as an option by calling oci_set_client_identifier() https://www.php.net/manual/de/function.oci-set-client-identifier.php

Code snippet of problem

$user = getenv('OCI_USER') ?: self::DEFAULT_USER;
$pwd = getenv('OCI_PWD') ?: self::DEFAULT_PWD;
$dsn = getenv('OCI_DSN') ?: self::DEFAULT_DSN;
$con = new Oci8($dsn, $user, $pwd, [PDO::OCI_ATTR_CLIENT_IDENTIFIER => $expectedIdentifier]);
$this->assertNotNull($con);

$stmt = $con->query("SELECT SYS_CONTEXT('USERENV','CLIENT_IDENTIFIER') as IDENTIFIER FROM DUAL");
$foundClientIdentifier = $stmt->fetchColumn(0);

System details

yajra commented 2 years ago

Provided another PR to set the client identifier via #101 & #102, and thanks for the tests on your PR. I got the idea there for another implementation.

Sevyls commented 2 years ago

Super, thank you