MySQL is an open-source, relational database management system.

learn more… | top users | synonyms

17
votes
6answers
16k views

Using wpdb to connect to a separate database

I want to connect wpdb to another database. How do I create the instance and pass it the database name/username/password? Thanks
18
votes
8answers
12k views

Why is my database import losing text widget data?

I've created a site in WordPress on our development machine. In the theme we're using there are numerous widget zones to display text in (sidebar and front page). I've used simple Text widgets in all ...
6
votes
4answers
2k views

the_date() not working

I am using wordpress 3.2 and I did a query post like this: <?php query_posts("posts_per_page=1post=type&page=post_parent=10");?> Then I try to echo out the date of this post I queried ...
14
votes
3answers
5k views

MySQL Database User: Which Privileges are needed?

The short installation instruction for WordPress ("5 Minutes") state that: Create a database for WordPress on your web server, as well as a MySQL user who has all privileges for accessing and ...
3
votes
1answer
466 views

Extending search query with additional $sentence value

Next in my quest to extend WordPress is altering how WordPress uses the the $sentence variable in posts_search to include an additional string, when the $sentence variable meets a certain criteria. ...
1
vote
2answers
3k views

How to validate WordPress generated password in DB using PHP?

I am working with site that is done with WordPress, and I need to add some parts that are outside WP, and to check user login, Logging users outside WP. I tried with md5 of password but it's not... ...
1
vote
2answers
440 views

wpdb Custom Meta Data with 2 conditions

This is one of those problems that I've spent way too much time on, and there is probably a VERY simple solution that I am missing. Any help would be greatly appreciated. I am trying to populate a ...
5
votes
3answers
1k views

Complex meta query with 3 keys

I think the problem essentially relates to sql query structure and I am not an expert.... I need to search for posts (custom post type) by 2 parameters: pd_city pd_country Please note that ...
1
vote
1answer
585 views

Use ajax to update_post_meta

2 days ago I asked this then I tried to work on my code to be able to understand how ajax and php work and now I have a new issue that, probably would be easily solved. These are my codes: <?php ...
0
votes
1answer
1k views

tag search using WP_Query

I need to find only posts with a tag forest gump. I've tried: new WP_Query('tag=forest+gump');, new WP_Query('tag=forest gump');. However they both return ALL the posts and not only the posts with ...
-1
votes
1answer
236 views

how to search through plugin in wordpress cimy-user-extra-fields?

I have a plugin clalled - Cimy User Extra Fields. I need to search the content through this plugin. This plugin is in WordPress, and all the content are stored in the database also, like industry, ...
4
votes
3answers
2k views

Optimize Multiple Taxonomy Term MySQL Query?

(Moderator's note: Title was originally: "query/database optimisation") I'm written a function for a custom "filter" search panel that allows users to select terms from up to four custom taxonomies. ...
6
votes
1answer
411 views

dbDelta support for FOREIGN KEY

On PHP 5.3.13/MySQL 5.5.21 the following code doesn't work: if($check_custom_fields_form!=1){ $sql = "CREATE TABLE IF NOT EXISTS ". $table_custom_fields_form ." ( `form_name` ...
5
votes
8answers
7k views

How to replace the domain name in a Wordpress database?

I have a Wordpress database which was installed in a development environment... thus, all references to the site itself have a fixed IP address (say 192.168.16.2). Now, I have to migrate that database ...
5
votes
2answers
280 views

WordPress database scalability from the code perspective

I have read through multiple questions here on StackExchange that concern WordPress scaling and the common opinion is that WordPress is indeed highly scalable provided you have the infrastructure to ...
1
vote
3answers
305 views

Delete post revisions on post publish

Is it possible to delete post/page revisions from the database when a post/page is published? 11/05/12 Answer: See the plugin below by bueltge I want to do this on a site with 5,000 posts and ...
0
votes
1answer
550 views

How can I debug my database connection for unit testing?

I've set up a wordpress environment on my Mac with MAMP and I'm running 3.5.1 locally (i.e. http://localhost:8888/blog works). I'm trying to run the unit test suit from wordpress.org and having ...
5
votes
2answers
615 views

Can i use php sql functions instead of $wpdb?

I'm new to WordPress and was wondering why in WordPress API do they tell you to use functions such as prepare(), insert(), get_col(), get_row(), query(), etc. when technically I can use the built-in ...
1
vote
3answers
461 views

Search and replace text across all posts

I had used the ZD Video Plugin for WP a long time, and now, since my move to WP 3.0.2, it doesn't work anymore. To embed a YouTube video using the plugin, I would just write ...
0
votes
1answer
126 views

Update some database fields when post is saved

I have a class that will count the Lines of Code, Source Lines of Code, and the Code disk space used. I would like to save these values into the database so that these values can be calculated only ...
2
votes
1answer
216 views

Multipart/formatted MySQL query problem

I'm creating a plugin and I want to automate the creation of a MySQL Trigger on a table. The problem seems to be that $wpdb->query doesn't appear to accept either multipart statements and/or formatted ...
2
votes
1answer
1k views

How to Delete Old Comments by Date?

I run a contest/giveaway blog at www.mommylivingthelifeofriley.com and currently have over 160,000 comments on 1100 posts. I would like to find a way to delete all comments from my site which are ...
1
vote
1answer
26 views

How to count post meta key values for all posts in database

In my post meta data I have the following 'key' for every post: "image_details" a typical value of which is an array such as: ...
1
vote
1answer
113 views

wpdb prepare syntax

$arr = []; array_push( $arr, 'wp_table', 1, '2013-12-24', 3, 'NULL'); $sql_prepare = "INSERT INTO %s (id, datea, one, two) VALUES (%d, %s, %d, %s) ON DUPLICATE KEY UPDATE one = VALUES(one), two = ...
1
vote
0answers
70 views

Regex to turn embedded images in to attachments

I've got a blog that has all images embedded in each post rather than a thumbnail linking to an attachment page which is what I'd like. I understand from this question that no plugin (like Regenerate ...
1
vote
1answer
263 views

Too many pages causes Wordpress admin to be unusable

We have a Wordpress website that now has around 9k pages in it after an import of many location targeted pages. The frontend runs perfectly fine and there is no performance damage (after I replaced ...
1
vote
1answer
250 views

How do I write this SQL statement for Posts written in last 24 hours?

Someone gave me this SQL code to count the number of posts (of post_type 'mixtapes') in the last 7 days. I tried to convert it to 'in the last 24 hours' as well, but it's giving the wrong number. ...
1
vote
1answer
972 views

Accessing WordPress MySQL Database via Data Connection in Visual Studio 2010 using C#

So I've Googled and followed countless tutorials, read documentation on MySQL, Visual Studio, WordPress, and Plesk. I try to leave posting on this site as the final option and it seems it has come to ...
1
vote
1answer
816 views

SQL query to delete comments older than 90 days?

I'm working on a site that has 150,000 comments with an obvious hit in performance; is there an SQL query that can delete all comments older than say 90 days? They're not spam comments, and they are ...
1
vote
1answer
780 views

Split WP install between 2 databases?

Is it possible for Wordpress to work from two databases? The reason I ask is that we're approaching our 100mb limit for database size on our host (1and1) but have up to 100 databases, so what I was ...
0
votes
1answer
58 views

Updating User Meta with SQL Query

I have a Wordpress site that needed to have 9,000+ users imported to set up a Directory Listing. I imported them from an existing MySQL (non-wordpress) database and everything imported just fine. ...
0
votes
2answers
232 views

Query multiple meta key values for template

I am using this template: http://demo.undsgn.com/studiofolio/front-page/ I tried to make some modifications because I need the homepage template to display an excerpt beneath each thumbnail. I copied ...
0
votes
1answer
324 views

“MySQL server has gone away” since update to 3.8

I have a WordPress install on a dedicated server with decent memory (upwards of 8GB). The WordPress install includes many plugins - 50 active plugins. Most important to note is the WPML plugin to ...
0
votes
1answer
34 views

Extending the database

I'm trying to add an extra column to the comments database which will store the user ID of the post/page author. This is part of a plugin which will display new comments in reply to either a post or ...
0
votes
1answer
88 views

Is altering a default WordPress database table update safe?

I want to add some table columns to the wp_terms table. Is it safe to use the dbDelta function with a modified CREATE-MySQL query for this? Or will I run into problems in the long turn? Is it update ...
0
votes
3answers
1k views

query to create woocommerce products from images

I have hundreds of art images in my WP media library, each of which I want to convert into a woocommerce product, and set as featured image of that product. Rather than manually adding new products ...
0
votes
1answer
55 views

How can I manage my multiple wordpress websites from main website?

Can this solution be used for multiple WP installations on the same site? For example, I have multiple blogs (multiple subdirectories), i.e. mysite.com/blog1, mysite.com/blog2, mysite.com/blog3, etc. ...
0
votes
2answers
247 views

How to copy post titles to post slug in phpmyadmin

I just imported 1000 post into a custom post type on a site and the slugs are all blank. There is a problem with the importing plugin i'm using. My SQL is weak :-/ know what i need to do but not sure ...
0
votes
1answer
94 views

Create a WordPress administrator without access to back-end

My site recently got hacked, and all my admin users lost their administrator level access. But when I access mySQL database, I saw all the users still exist. How can I create an administrator when I ...
0
votes
1answer
359 views

SQL query not working in alphabetical post title/content search

I have an ajax request using wp_ajax sending one variable named "q" what I want to do is after the script get's the request to look inside the db and fetch the title and id of the corresponding posts ...
0
votes
1answer
302 views

MySQL query performed 4 times inside loop

I have enabled custom php in my pages through the use of the exec-php plugin so I can run more complex pages than the standard WordPress page. I have had no problems with this plugin so far. I have ...
0
votes
1answer
1k views

Wordpress $wpdb get posts from category and sort by custom meta

I have a custom post type of 'events' which has a meta key 'event_date' Im using the following to retrieve those posts and arrange them by 'event_date' global $wpdb; $today = ...
0
votes
2answers
699 views

Help!! I Screwed up my WP

I was trying to clear up some empty tables left behind by other previously used plugins. As such i was trying to delete the GD Star rating plugin and now I cannot access my WP admin. i get the 'You do ...