Reputation: 1623
I'm working on a WordPress plugin where I'm trying to fetch some basic information about the kind of database installed.
The information I need are as follows:
Now I know I can get the database version easily by running the following query:
$wpdb->get_var("SELECT VERSION() AS version");
But I have no idea about how to get the database software name.
Does anyone knows any way to get this details?
Upvotes: 0
Views: 135
Reputation: 24960
see the tables in the INFORMATION_SCHEMA
db with a use
and show tables
and poke around.
SELECT variable_value
FROM INFORMATION_SCHEMA.SESSION_VARIABLES
WHERE variable_name IN ('version_comment','version_compile_os','version_compile_machine','version','innodb_version');
+------------------------------+
| variable_value |
+------------------------------+
| 5.6.31 |
| Win64 |
| x86_64 |
| MySQL Community Server (GPL) |
| 5.6.31-log |
+------------------------------+
MySQL Manual page entitled Chapter 22 INFORMATION_SCHEMA Tables.
Upvotes: 2
Reputation: 133380
In PHP if you use PDO driver you can use can use PDO::getAttribute()
with PDO::ATTR_DRIVER_NAME
:
assuming $conn is your connection you can retrive the related db driver with
$dbDriverName = $conn->getAttribute(PDO::ATTR_DRIVER_NAME);
you can check if you have the vars
$DB_HOST,
$DB_USER,
$DB_PASSWORD
$DB_NAME
then you can try a new connection
$conn = mysql_connect($DB_HOST, $DB_USER, $DB_PASSWORD, $DB_NAME);
or you can import wp-config.php for get the db connection param see this for a suggestion https://wordpress.stackexchange.com/questions/162614/how-to-make-connection-to-wordpress-data-base-in-a-plugin
Upvotes: 2