How to ride WordPress and use it’s database configurations to create our own tables and columns



When making a WordPress plugin sometimes we need to do some database operations, such as making table, adding column, inserting new data, updating data and so on.

We can use current WordPress database connection that has been established before so we can just ride it.

To do mysqli query operations, PHP requires us a connection variable… We can use that one that WordPress uses. So for example if we want to do this command:

mysqli_query($connection, "Blablabla...

That $connections can be defined this way:

global $wpdb;
$connection = $wpdb->dbh

By having $connection variable, we can do any database operational thingies as we want, such as making database table, adding column, inserting, updating and so on…

loading...

Leave a Reply

Your email address will not be published.