?
Solved

Wordpress Database

Posted on 2015-02-11
2
Medium Priority
?
70 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 2000 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Now that you've installed WordPress 2.9 (http://www.experts-exchange.com/articles/Web_Development/Blogs/WordPress/WordPress-2-9-What-to-Expect-When-Upgrading-to-WordPress-2-9.html?) on your site, you need to install some plugins to get the most out …
Like there are many different versions of Wordpress, there are also a handful of related side projects WordPress users should be familiar with.   All of these projects are open source and GPL licensed, which means there are few restrictions to us…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
Suggested Courses

839 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