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

learn more… | top users | synonyms

0
votes
0answers
3 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
25 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' ")); ...
0
votes
2answers
83 views

Installing local to live WP into subdirectory

I am having a bit of trouble moving a local WP site live and into a subdirectory. I want a static homepage for now (index.html in the root folder) while I work on the live site (would be found in ...
1
vote
1answer
56 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
1answer
221 views

Contact form with database integration issue

This is more a question about the idea I am going to share and ask for advice for. I would like to have a contact form on my site, where people complete their data and it gets stored inside a ...
0
votes
2answers
426 views

MySQL Syntax Error upon restoring database from backup

Performed a bad import to my Wordpress install and decided to restore from the mqSQL backup (full export) I had made minutes earlier. Dropped all tables in the database and then did an import from my ...
0
votes
0answers
82 views

How to display the image of first product in a woocommerce category as it's category image?

After an import of products to woo commerce system, I am faced with an issue where I have 50+ categories without any featured image and limited time. Assigning them an image manually will be tedious ...
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
0
votes
1answer
242 views

use wordpress to create user on external database

let me try to explian what i wanna achieve, I have wordpress site and a project management system from codecanyon here is the link. http://codecanyon.net/item/freelance-manager/1225423 i have ...
0
votes
1answer
216 views

How to check for empty and not a failure

I'm querying the postmeta table to see if a url has already been entered, using this statement (where $thisLink is the url I'm checking) $mypostids = $wpdb->get_results("select * from ...
0
votes
0answers
22 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
17 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
35 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 ...
3
votes
2answers
6k views

Connect to database using wordpress wp-config file

How can I connect to the database using the wp-config.php file ? I'm trying to make a script more Wordpress friendly, and I need to connect to the database, but without installing the script as a ...
1
vote
1answer
19 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 ...
8
votes
1answer
286 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 ...
1
vote
1answer
20 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
vote
1answer
260 views

How to optimize 'select found_rows()' query? Several 'high load average' alerts daily

I have 5,000 regular posts, 6,000 posts in one post type and 2,000 posts in another post type. Needless to say, that has made the wp_posts table quite large. Not to mention, I have custom taxonomies ...
-1
votes
1answer
25 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
19 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
1answer
541 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 ...
2
votes
2answers
248 views

Grouping related postmeta data via SQL query

I am using someone else's WP plugin which stores lots of related data in wp_postmeta using an "artificial key". So effectively we hijack wp_postmeta to create a nested relational database. So one row ...
0
votes
2answers
59 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 ...
-1
votes
0answers
21 views

InnoDB full text search with WordPress

Now MySQL 5.6 support full text search on InnoDB, is it possible to make WordPress use of the full text index to speed up the search?
0
votes
1answer
766 views

Advanced Custom Fields Array Population

I'm trying to populate a ACF select field with an array from a custom $wpdb->get_results call, which is essentially a list of categories from my db. I have the following: global $wpdb; ...
1
vote
1answer
57 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 ...
1
vote
1answer
37 views

Query Wordpress database by registered date and role

I would like to get the display name and email address for all users who have registered to my multisite today with the role of subscriber. It needs to be an SQL query as it's used outside of the WP ...
1
vote
1answer
228 views

How to let a user choose an authors and save it to the database?

I have a multi-author Wordpress site which reads different rss feeds and posts them to my page. I was wondering if it is possible to make a code that would provide an opportunity to registered user ...
0
votes
0answers
19 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: ...
2
votes
1answer
2k views

Get Previous & Next posts by Post ID

How can I go about getting the previous and next posts from outside the loop? Everything I try to do aside from the custom SELECT query (using get_posts or WP_Query) breaks stuff further down the ...
0
votes
4answers
92 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 ...
0
votes
1answer
22 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
6 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 ...
1
vote
2answers
1k views

Help with MySQL to $WPDB query

Here's my issue. I have three tables I'd like to query - states, points, and state_points. States contains stateid, and name. Points: pointid, pointlat, pointlng. State_points: Stateid, Pointid. ...
2
votes
2answers
77 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
1answer
51 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. ...
1
vote
1answer
2k views

How to get a Google maps SQL->XML->map marker tutorial to work in WordPress

I have been trying to figure out what is wrong with my code for a couple days now, and I cant seem to crack it. I am trying to follow this tutorial: ...
0
votes
0answers
33 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
42 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
2answers
561 views

Woocommerce: Grab total revenue of a product over all orders

I need to display the total revenue of all orders for my products depending on if the logged-in user is the author of the product or not. I can't use the Quantity field as a multiplier either because ...
1
vote
0answers
24 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
17 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 ...
0
votes
2answers
19 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
49 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
29 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
26 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
27 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
1answer
26 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
31 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 ...
0
votes
0answers
39 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 ...