Solved

Wordpress Database

Posted on 2015-02-11
2
61 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

WordPress has made it easy to create scalable sites based on their powerful CMS, but as great as WordPress is, there are some SEO issues that haven’t been addressed out of the box.  Fortunately these problems can be solved with a few plugins.  The f…
WordPress is constantly evolving, and with each evolution appears to get better and better.  One of the big drawbacks prior to version 3 was that there was no way to be able to set up a custom menu from the backend. The Old Way Adding menus is…
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…

863 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

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now