Page 1 of 1

is it possible to query pdo object for database file name ?

Posted: Wed May 05, 2010 5:17 am
by madrazel
in php I declared database object:

Code: Select all

$pdo = new PDO('sqlite:mybase.DB3');
i know how to get information about engine used in this connection, which is:

Code: Select all

$pdo->getAttribute(PDO::ATTR_DRIVER_NAME);  // ---> string 'sqlite'
But I do not know how to get back the actual database file name (that is 'mybase.DB3') back from this object. Is it possible to be done from query to the database itself (maybe some kind of PRAGMA) or from query to the object.

Re: is it possible to query pdo object for database file nam

Posted: Wed May 05, 2010 6:15 am
by Zyxist
AFAIK there is no method or attribute that returns the PDO DSN. However, is it a problem for you to store it in some variable and access it through it? I'd do that in this way.

Re: is it possible to query pdo object for database file nam

Posted: Wed May 05, 2010 7:33 am
by madrazel
The solution is to query the database itself:

Code: Select all

PRAGMA database_list