Нет, встроенной функции нет.
Но вы можете расширить class MyPdo extends PDO
, проанализировать и сохранить dsn и вернуть его с помощью какого-либо средства доступа
class MyPdo extends PDO
{
...
/**
* @param string $dsnParameter
* @param string|null $default
* @throws RuntimeException
* @return string|null
*/
public function getDsnValue($dsnParameter, $default = NULL)
{
$pattern = sprintf('~%s=([^;]*)(?:;|$)~', preg_quote($dsnParameter, '~'));
$result = preg_match($pattern, $this->dsn, $matches);
if ($result === FALSE) {
throw new RuntimeException('Regular expression matching failed unexpectedly.');
}
return $result ? $matches[1] : $default;
}
...