Solved

Wordpress Database

Posted on 2015-02-11
2
59 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
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
Transferring a wordpress site from a host or local dev server to another host can be a pain. So I've included my steps on how I have accomplished this task. Steps include an assumption that you have Cpanel access or Ftp access.. If you do not hav…
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

771 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

10 Experts available now in Live!

Get 1:1 Help Now