pg_dbname
PHP function
Edit on GitHub ✎
(PHP 4, PHP 5, PHP 7, PHP 8)
Get the database name
Description
pg_dbname(PgSql\Connection|null $connection = null): string
pg_dbname() returns the name of the database that the given PostgreSQL connection instance.
Parameters
connectionConnection-with-nullable-default
Return Values
A string containing the name of the database the connection is to.
Changelog
| Version | Description |
|---|---|
| 8.0.0 | connection is now nullable. |
Examples
pg_dbname() example
php
<?php
error_reporting(E_ALL);
pg_connect("host=localhost port=5432 dbname=mary");
echo pg_dbname(); // mary
?>