Solved

Wordpress Database

Posted on 2015-02-11
2
65 Views
Last Modified: 2015-02-11
Is it possible to sidestep the $wpdb class (for accessing the WP database) and just use plain old MySQL queries constructed in php?

I'm talking SPECIFICALLY about accessing tables I added to the WP database.

If the answer is yes, how do I get the WP connect string data (host, user name, dbname & password)?

Thanks
0
Comment
Question by:Richard Korts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 38

Accepted Solution

by:
Tom Beck earned 500 total points
ID: 40604307
Yes, same as any php connection to a MySql database:
// LOCAL CONNECT TO THE DATABASE
$DB_NAME = 'myDatabase';
$DB_HOST = 'localhost';
$DB_USER = 'testuser';
$DB_PASS = 'myPassword';


$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);


if (mysqli_connect_errno()) {
	printf("Connect failed: %s\n", mysqli_connect_error());
	exit();
}

Open in new window

Get your connection string information from the wp-config.php file.
0
 

Author Closing Comment

by:Richard Korts
ID: 40604457
Thanks, I figured out the location (in wp_config) myself. Looks pretty simple.

But based on the other question / result, I will probably try to forge on with $wpdb.

Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how i fix Remove render-blocking JavaScript 3 104
WordPress - Timber - Single post not rendering 2 37
Wordpress DB connection error 4 33
I need help upgrading my urls 5 32
Did you use a default hosting installation of wordpress with the intention of it being your actual site?  Maybe you’ve installed it as a Blog to your current site and recently converted it to be the main site and do away with the old .htm pages.  An…
If you are looking for plug-ins to add functions to your WordPress small business web site, take some time to read though this comprehensive list.  These are all the plugins I use for my customers WordPress web sites, as well as my own.  Be sure to …
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question