Is there a way to get the table prefix after connecting to the database?
I use wordpress and I need to get the table prefix, but outside of the whole wordpress installation. My script is currently connecting to the database, but I need a table prefix to be included in some parts of the script.
Any idea?
Thanks in advance
<?php $root = realpath($_SERVER["DOCUMENT_ROOT"]); require "$root/wp-blog-header.php"; function get_table_prefix() { global $wpdb; $table_prefix = $wpdb->prefix . "outsider_plugin"; return $table_prefix; } // echo get_table_prefix(); ?>
Thanks Mac, your idea will help me solve the problem using a similar approach.
create any php file, outside wordpress, <?php require('wp-blog-header.php'); echo $wpdb->base_prefix; ?> <?php require('wp-blog-header.php'); echo $wpdb->base_prefix; ?>
<?php require('wp-blog-header.php'); echo $wpdb->base_prefix; ?>
Please use the correct path for wp-blog-header.php in require
wp-blog-header.php
require
Source: https://habr.com/ru/post/1416512/More articles:Does the Kadane Max Sub Array algorithm work on an entire positive integer array? - javascriptHow to write cmake for a library? - librariesWill iOS shut down the application in the background after a certain time? - iosBest CMake practice for installing a library - cmakehow to catch hara-kiri in django - djangoPaste XML node in first position using XSL - xmlHow can I get a Windows product key in C #? - c #Mongodb runs on timestamp in long - javascriptjQuery - scaling function of several sections in proportion to the height of the window - functionCalculate zip file size with compression level 0 - c #All Articles