I use PDO in PHP to connect to a PostgreSQL database. Does it allow setting the application name when making this connection?
try {
$conn = new PDO ( 'pgsql:host=' . $host . ';dbname=' . $dbname, $user, $pwd );
//$conn->setAttribute ( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
} catch ( PDOException $e ) {
showError ( "Error", 2 );
}
You can add to the DSN string a new element called options with value:
--application_name=YOUR_NAME_HERE
$conn = new PDO(
"pgsql:host=$host;dbname=$dbname;options=--application_name=YOUR_NAME_HERE",
$user,
$pwd
);
Credit goes for this old user comment in PHP manual.