9951 explained code solutions for 126 technologies


php-pdoGet current database name with PHP PDO


$db = $pdo->query('SELECT database()')->fetchColumn();ctrl + c
$pdo

PDO connection object

query(

executes specified SQL and return PDOStatement

SELECT database()

SQL query that will show current database name

fetchColumn

will return single column value

$db

variable will contain database name