iSaumya iSaumya - 2 months ago 6
PHP Question

How to get basic database information in PHP

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:


  • Database Software: it can be MySQL, MariaDB, Oracle or anything else

  • Database Version: I know how to get it



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?

Answer

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.