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

learn more… | top users | synonyms

2
votes
1answer
53 views

Using $wpdb Class to Pull Recent Comments Across a Network

Been looking for a clean and simple way to produce comments from across a network using the $wpdb database class. I did find this answer, which has been protected, and is four years old. I wrapped ...
1
vote
0answers
30 views

Delete duplicate rows from wordpress database where a column is duplicate in phpmyadmin

I have a wordpress table like so (phpmyadmin and MySQL) | id | meta_key | meta_value | +----+-----------+------------+ | 1 | import_id | abc | | 2 | import_id | abc | | 3 | ...
0
votes
0answers
41 views

wp_insert_post another database with custom field

wp_insert_post with the command you want to transfer the contents to another database, I use the following command <?php require('wp-config.php'); $conn = mysql_connect($dbHost, $dbUser, ...
0
votes
1answer
82 views

$wpdb->get_var - What value is returned when zero records are found?

I have the following code: $queryPermission = $wpdb->get_var( $wpdb->prepare("SELECT Active FROM testers WHERE user_id = '$user_id' ")); ...
1
vote
1answer
110 views

Wordpress database error - Error in SQL syntax - I can't identify any error?

I am trying to write function that checks whether an email address is stored in my database or not. I've written the following PHP code:: function check_my_users( $email_address ) { global ...
0
votes
0answers
51 views

Import posts into SQL

Is there a way to bulk import posts directly into the database? like from csv into sql database. I don't want to use those csv import plugins since they don't always work they either only import half ...
1
vote
1answer
151 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: ...
0
votes
0answers
71 views

SQL query to remove first image in all posts

I've built a site up over a few years (3,500+ posts) where I've inserted images using the traditional method into the post content itself. I'm now moving to a different theme, and have made the first ...
1
vote
1answer
30 views

I want to select the from values from database in WordPress? [closed]

Here is my code: $sql = 'SELECT * FROM ' . $wpdb->base_prefix . 'item WHERE uname = "'. $_POST['login_name'] . '" '; $result = $wpdb->get_results($sql) or die(mysql_error()); foreach($result as ...
1
vote
1answer
25 views

Why doesn't this code add a table to my database?

To get to the point, I'm trying to add a database table upon installation of my plugin. Here's my code: global $scimp_db_version; $scimp_db_version = "1.0"; function scimp_install () { global ...
-1
votes
1answer
63 views

Remote database -> massive response time increase?

I have nginx web server running newest WordPress and DB server running MySQL 5.6 There is around 90-100ms latency(round-trip delay) between those 2 servers. The problem is that It takes about 5000 ...
1
vote
1answer
55 views

$wpdb->wp_users returning empty value for

I have a code Example: function custom_func(){ global $wpdb; $wpdb->flush(); //tried with and without this line $getTest = 'SELECT * FROM $wpdb->wp_users LIMIT 1'; ...
0
votes
2answers
404 views

Different database query in function.php using mysqli

I am trying to connect to a database in the function.php using mysqli. The code seems to run fine when it is not on a separate php file not on wordpress. But when I run it on wordpress I get "Connect ...
0
votes
0answers
48 views

Best way to execute custom page-specific mysql queries

I would like to query a secondary mysql database (not the Wordpress mysql database) with page-specific queries. I've seen many answers / tutorials on setting up a secondary mysql database, like: ...
0
votes
1answer
41 views

wp_postmeta - lot of meta fields

I found a lot of meta_key + meta_value fields in my database in wp_postmeta. They are all same only meta_id and post_is changign. And there is more than thousands of them. Look at the pic. Should I ...
0
votes
0answers
9 views

Archive list with only years and months belonging to a category

I need to generate a list of years and months belonging to a category. For example I have two main categories (A and B). I need a list of years and months of post published only of the category A and ...
0
votes
1answer
122 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
1answer
302 views

wpdb->insert multiple record at once

So after I have created the table 'settings-table' i want to add a couple of records to it. This is how I want to do it, not the best way, so I need a better way to do this because I will add more ...
0
votes
0answers
92 views

MySql Query very slow

I have a problem with a query on my website. When I load the page it is incredibly slow and only after over 12 seconds the content starts showing. I have installed a debug plugin and found the query ...
0
votes
4answers
128 views

Strange wordpress slowness

I read a lot about my problem. I have 4 years old Wordpress (with newest 3.8.1 Wordpress) site. And last months it become really slow. It takes about 3-5seconds to render page. In administration area ...
1
vote
0answers
37 views

Calculate average crossing post categories

In my WP database I have some posts i the category hotels and some other posts in the category visits. In the posts (placed in the category visits) there is two meta_fields ( rating and placeid ) ...
0
votes
0answers
31 views

wp_term_relationships has term_relationship_id of 0, causing issues with backup

After bulk tagging posts via mysql, I may have inserted a bunch of rows into my wp_term_relationships table that have a term_taxonomy_id of 0. I believe this causing issues when i try to backup the ...
8
votes
1answer
558 views

Why are simple updates to wp_postmeta's “_edit_lock” so slow?

In our MySQL slow query log, the cumulatively slowest query is a simple update to wp_postmeta. Here's an example: UPDATE `wp_postmeta` SET `meta_value` = '1392835505:386' WHERE `post_id` = 94705 ...
0
votes
2answers
22 views

Exporting completed webiste for another server

I've been working on a Wordpress website with WooCommerce etc for my friends business for a while. It's pretty much done, all products are added etc. However this has been done on my own webhost / ...
0
votes
1answer
87 views

List users with the most posts in the last 30 days

I'm trying to create a MySQL query to display a descending list of users with the most number of posts over the last 30 days. This is not working with me: $where .= " AND post_date > '" . ...
0
votes
0answers
44 views

Using the same shortcode to show any table from the database

I have a little question for you. I want to create a shortcode that makes a table with data that I have stored in a database. But i want to send the shortcode an attribute, to specify which table ...
0
votes
1answer
72 views

Using <?php echo get_num_queries(); ?> queries in and i see 7000+queries?

I have put queries in seconds. in my footer.php and i see more than 7000 queries in about 9 secs , is this a lot?? On my localhost i have 195 queries in 3,070 seconds. As the live ...
0
votes
1answer
45 views

Plugin data shared in Multisite

I am trying to build a site that very closely resembles another and so far so good with WordPress Multisite Networks. I am also using the plugin WP-FileBase - this plugin creates a database table per ...
0
votes
0answers
52 views

Choosing the right server for a big WordPress site with buddypress

I started working in a WordPress site with buddypress and I need to choose a server. They have 1.9 million users in the database and they are estimating to have like 250,000 views every month. The ...
0
votes
1answer
30 views

Linking Plug-In Files to WP

I am writing a plug-in right now which adds a table to the database when activated. I have another file in my plug-in directory which handles a form submission and writes to the database. This file ...
0
votes
1answer
49 views

Query the database after get_header() has been included

I'm trying to create a custom template. Iv'e searched a lot but cannot find how to query the database once the get_header() is added to the page. What I am looking for is for PROPER ways to query ...
1
vote
0answers
34 views

Writing into MySQL Table

I'm trying to write some data from the frontend into a custom database table. As long there is no value in the input field this script creates an empty line in the database table, but if the input ...
2
votes
2answers
95 views

WordPress for a very large website

I've searched and searched but I did not find an answer online. Also, I've posted this on StackOverflow and apparently it wasn't ok and I reposted this here. I hope it's ok. I have this website which ...
0
votes
0answers
51 views

Renaming admin user on multisite install by MySQL

As part of a general tightening of security, I want to change the name of the admin user on my multisite install to something less commonly used. This user is admin on all five sites in the network ...
0
votes
1answer
104 views

Using mysql to replace img src?

I tried to use the Enable Media Replace Plugin to replace some images on my site with updated versions. There is an option to update all instances where the file is used on the site, but this only ...
0
votes
1answer
383 views

meta_query on a date range using an array of values

How can I do a query to return the post if the custom field array contains a date that is within the specified range? The query below is basically what I am after but it does not work... // the ...
0
votes
1answer
17 views

meta_query dates from an array

I have the below query which isn't returning anything. The query is meant to look for the date (2014-03-01) that is in the array, which it is. Any ideas? Or would I need to use a custom SQL query? ...
0
votes
1answer
70 views

Calling mysql_query() on another database, assumes WordPress using that database

I'm attempting to import some data from a legacy site into WordPress. First step is terms for taxonomy event_category. Here is my approach: $link = mysql_connect( 'localhost', 'blah', ...
0
votes
2answers
469 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
0answers
20 views

Queries gone haywire since update to 3.8.1 [duplicate]

I have a WordPress install on a dedicated server with decent memory (upwards of 8GB) Since upgrading to 3.8, I started getting mysql disconnects/timeouts, better known as MySQL server has gone ...
0
votes
2answers
660 views

How to return number of found rows from SELECT query

I wrote a function which is supposed to return the number of rows found in a SELECT query but it always either seems to return 0 or an array. I have been messing around with this for about an hour now ...
1
vote
1answer
89 views

How to determine what is generating large amount of database queries?

For some reason, my Wordpress site is using a lot of memory (spiking at 72MB) and generating a huge amount of database queries (76923 according to Wp-Memory-Usage. I'm really not sure why this would ...
0
votes
1answer
146 views

Add row to custom database Table and delete all rows older than 1 day

I'm editing a view counter plugin so that it logs the IP of every user that viewed a post. This is to prevent them from refreshing the page and thus creating artificial views. The part I'm having ...
0
votes
1answer
31 views

Splitting One Big WordPress Site into Multiple Small Sites

I have a very big WordPress site and I am facing speed issue and server resources issues. Specially numbers of MySQL records are so high. So, I want to split the big WordPress site into multiple small ...
0
votes
0answers
32 views

Moving WordPress site to a new server - Admin not loading

I'm trying to move a WordPress Database from one server to another. I've done this a few times with other sites and servers and I use Sublime to do the find and replace and I've had no issues up to ...
0
votes
1answer
28 views

Why do mass updates to post_content shows in front end, but not in edit screen?

We had someone migrate several blogs in Movable Type to Wordpress recently, but we just realized they missed some of the content that was in a database field in MT labeled *entry_text_more*. For ...
0
votes
1answer
466 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 ...
1
vote
1answer
323 views

Successful or Error Message after running mysql code in functions.php

Just for this article, suppose there is a code that I want to run on my WordPress' functions.php file. It's a code to delete mysql table on my database. For example, here's the code: $wpdb->query( ...
0
votes
0answers
69 views

Unable to install WordPress on Plesk 11 Windows based machine

I am trying to install WordPress on a Windows server. The install was not able to create wp-config.php itself, so I created it and put in the database values. Now I get errors like this table doesn't ...
0
votes
1answer
20 views

optimise SQL wordpress call

I have this code : $querystr = " SELECT * FROM {$wpdb->prefix}posts INNER JOIN {$wpdb->prefix}postmeta m1 ON ( {$wpdb->prefix}posts.ID = m1.post_id ) INNER JOIN {$wpdb->prefix}postmeta ...