MySQL is an open-source, relational database management system.
0
votes
1answer
96 views
Can't create tables with my plugin
Here is the code:
<?php
/*
Plugin Name: MyPluggin
Plugin URI: http://localhost/
Description:
Version: 0.0.2
Author: localhost
Author URI: http://localhost/
License: GPL2
*/
...
5
votes
2answers
159 views
Lack of composite indexes for meta tables
Why wp_commentmeta table does not have a composite index (comment_id, meta_key) by default? I believe it's the only useful index for that table, am I wrong?
Instead, it has a strange set of indexes:
...
1
vote
0answers
126 views
wp_admin edit.php slow with lots of queries
I have about 4,000 posts. Currently when I click on All Posts (edit.php) it's taking about 10 seconds to load and I'm showing approximately 1000 queries!
Most of them look like...
SELECT t.*, tt.* ...
0
votes
1answer
84 views
Using custom tables for old posts
I have a site with about 24,000 posts and 200 posts daily and the database will get huge soon. So I plan to transfer the old posts to custom tables to reduce the database load. There's no need to show ...
1
vote
1answer
67 views
How to adjust code to refresh a dropdown box with tags that are active on filtered category listing
I have multiple custom tags setup (ptags) and custom posttypes (products) and made it so i can filters posts by multiple tags in a category.
Currently the code retrieves tags from posts relating to ...
0
votes
1answer
22 views
Assign a tag to custom post type using a query
I have a custom post type courses with a custom field level. I want to run a query (mysql or WP query) that runs through every course (post) and if the level is greater than 3, append a tag called ...
0
votes
1answer
167 views
wp_insert_post - duration
i try to import a custom DB to the WP DB with about 2000 rows (custom post type).
the problem is that the insert by wp_insert_post takes about a second per insert.
Is this normal ? Is there a ...
1
vote
2answers
215 views
How to do a MySQL dump from production site without using a search and replace script for local development?
I performed a MySQL dump of my WordPress production database to be imported into my local development environment. I plan on frequently performing this database dump and import. Is it possible for me ...
1
vote
1answer
110 views
MySQL Rank & $wpdb
I need a rank column in my MySQL statement, for example:
SET @rank=0;
SELECT @rank:=@rank +1 as rank, player, points
FROM my_table
Is there a way to use the above with $wpdb? WordPress doesn't ...
0
votes
1answer
137 views
Defining the same price to all WooCommerce Products
All of my products on my site are $1 and during an import I did using WooCommerce import it didn't save all the _regular_price & _sale_price values, so there is no way for the user to buy that ...
0
votes
1answer
125 views
Wordpress: Using the category slug get the category ID using mysql query
basically, I have a cookie with the category slug stored, using this data I want to query the database and return the ID of the category.
I am new to mysql and this seems like an advanced query that ...
5
votes
6answers
16k views
What SQL Query to do a simple find and replace
Whenever I create a new website I first create a staging site on a subdomain like "stage.domain-name.com".
After everything works correctly I export the database, open it in notepad++ and do a ...
0
votes
2answers
105 views
How to update wp_posts with just the returned comment count from wp_comments (SQL GROUP BY)
I am doing a special migration from someone's custom CMS to a WP installation. I successfully got the posts and comments migrated into their respective tables. Now I need to get the comment count ...
0
votes
1answer
138 views
SQL query - get ids - Advanced Custom Fields / WPeC
I need to query the database on add_action( 'init', '...') to find post ids with the field 'product_discount_option' set to true.
I know at least one of my product posts have the field ...
14
votes
6answers
10k 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
1
vote
1answer
316 views
Is It Possible to Restore Accidentally Deleted Widgets?
I accidentally deleted the widgets without dragging it to the inactive widgets section.
I have a backup of all the files and the database but i have changed many things on the site other than the ...
0
votes
2answers
92 views
Wordpress $wpdb no result
I have the following code in my functions.php
$code = 'EUR';
global $wpdb;
$query = 'SELECT * FROM ';
$query .= $wpdb->get_blog_prefix() . 'fxbase ';
$query .= 'WHERE code= '.$code;
$data = ...
0
votes
2answers
124 views
get last post's link with SQL query
I have installed a WP on website A and I want the last post's links in site B.
I haven't in site B any WP and I want to get the link of last post from website A.
so I can't use WP API like WP_Query ...
0
votes
0answers
47 views
What is a good database backup? [closed]
I am transfering my site to another site (different server and domain) and would like to export my previous database. I am following these steps. When exporting my database the first time. I had a ...
0
votes
2answers
94 views
How and where is wordpress adding mySQL content to database?
I am currently following this steps to change server and domain for my website. I have been exporting and importing mySQL from one data base to the other. I am about to delete the mySQL content of the ...
0
votes
1answer
54 views
Does WordPress cache get_user_meta() results?
If I call get_user_meta() to retrieve a value, does WordPress cache the value? If I call get_user_meta() to retrieve the same value, does WordPress have to query the database again or is it stored in ...
4
votes
2answers
1k views
Get posts by menu ID
I'm a little stuck here. I have a menu in Wordpress with some posts in it.
What I would like is to retrieve all the posts as objects.
I think I'm pretty close, but the SQL query doesn't seem to work ...
1
vote
3answers
221 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 ...
1
vote
0answers
170 views
WordPress Query wp-terms SLOW
I've got a very large database in WordPress with lots of products in WooCommerce along with quite a bit of taxonomies. When querying the products on the front end it takes 1 minute or more.
Here is ...
2
votes
1answer
255 views
How to disable `SQL_CALC_FOUND_ROWS` [duplicate]
Possible Duplicate:
wordpress query causing load
In the site I'm trying to optimize, I noticed several queries that are rather slow and start with SELECT SQL_CALC_FOUND_ROWS
Searching this ...
2
votes
3answers
247 views
Programmatically changing role information; editing role name and deleting
I am making system where I am delegating a lot of functionality to the front end of a system using Wordpress. I have listed all the roles (most of the custom) and need to ability for a logged in user ...
0
votes
1answer
331 views
Change featured image urls in database
Im storing my images on another server and Ive managed to change the urls in the database but I cant seem to change the featured image urls?
I will not be adding any more images so I just want to ...
0
votes
1answer
211 views
Help with WP_Query - Too many mySQL queries
I need some kind of help with wp_query. Am I doing something wrong? I am getting a lot of mySQL queries, while building a new theme.
My WP_Query is:
<?php
$args = array(
'post_type' => ...
0
votes
1answer
56 views
sql for querying post and their category
I'm trying to query the wordpress database for the post and what category they belong in. Is there a sql query that I can use for this?
Thanks,
4
votes
2answers
2k views
WooCommerce with thousands of products - site is very slow - optimize db queries?
So far I've got around 8,000 products in my WooCommerce and the product page on the front end takes several seconds to load, even after caching.
My VPS host says that I should have multiple ...
0
votes
2answers
775 views
Getting “Error Establishing a Database Connection” on localhost in new Mac OSX Lion environment
I just got a new Macbook Air and I've been manually migrating my files and code over from my old Macbook (instead of using Migration Assistant, to avoid bringing cruft).
I had several sites running ...
0
votes
0answers
6 views
What would make a MySQL database create tables in a different collation other than its default? [duplicate]
Possible Duplicate:
Using wpdb to connect to a separate database
am adding tables to a Wordpress database on my localhost and it is changing my collation from utf8_general_ci to ...
2
votes
3answers
3k views
How do you properly prepare a %LIKE% SQL statement?
I'd like to use a LIKE %text% statement while still using the WordPress $wpdb class to sanitize and prepare input.
SELECT column_1 from `prefix_my_table` WHERE column_2 LIKE '%something%';
I've ...
3
votes
1answer
278 views
What specific database privileges does WordPress need?
I want to create a new database user for my WordPress installation. Usually on localhost, i can just use root, but it is good practice to use a user with as little rights as possible.
What are those ...
1
vote
2answers
157 views
$wpdb: Counting posts corresponding to 3 terms in 3 different taxonomies
It's easier if I made an example:
I have a custom post type MYPOSTTYPE, with 3 taxonomies TAX_1, TAX_2 and TAX_3
If I have 3 terms: 'TERM_TAX_1' in TAX_1, 'TERM_TAX_2' in TAX_2, and 'TERM_TAX_3' in ...
0
votes
1answer
225 views
Get post featured image id with $wpdb
I'm not a sql expert, but with some help and copying from queries I've found on the web I got this working one that gets the 20 closest places (custom post type) to a specific latitude and longitude ...
2
votes
1answer
43 views
can database and media folder be moved to a different drive?
I have to move my site from Drive C:\ to Drive E:\.
Is there a better way to do this than uninstalling the following:
Wordpress
PHP
MySQL
Apache
and re-installing on Drive E:\?
For example, how ...
1
vote
4answers
269 views
Migration: Copying database content to a different server
I'm migrating our WordPress site from one server to another. I need some hint on how to deploy a database dump (which I have) from the original server to the new one. There is no phpmyadmin (at least ...
0
votes
1answer
197 views
Integrating Custom Database with Wordpress
I Have a Wordpress Site with few users who are my college students
They Registered using their RollNumbers/HallTicket Numbers as their usernames in Wordpress site
Now I Have Another Database with ...
5
votes
2answers
383 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
65 views
how would I create a custom query to get all users, and a related post based on a postmeta field?
I have about 50 users. Its pretty easy to list them all. However they are related to a special custom post type through a postmeta field called wpp_agents.
So I need to list Users, but also the ...
5
votes
1answer
292 views
How does Wordpress handle MySQL row lock errors?
If there is a WordPress plugin which updates rows in a custom table, but that update encounters a row lock, what happens? E.g. two users simultaneously fire an update on TABLE1, one setting AGE=1 and ...
4
votes
2answers
2k views
Checking if Database Table exists
I read the wordpress codex and professional wordpress. It seems both use something like
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
to determine if the table exists. Is ...
3
votes
1answer
262 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
495 views
WordPress Custom Query
I have posts that use a custom field for start date and end date.
query_posts returns an array of posts that exist in the category I'm filtering.
How do I query posts using this custom field that has ...
2
votes
1answer
35 views
What is the most secure way to set up the MySQL user in WPMU?
I am setting up Subdomain based MU on my domain.Everything is hosted by me running on one CentOS/Webmin VPS. Will I be better off setting the MySQL user's domain as localhost, 127.0.0.1 or with a ...
1
vote
1answer
82 views
Custom order for Mysql array
I have a Page of Posts, each post has a Custom Field "expired" which contains a date in the format YYYY-MM-DD which is used to order the posts. This date is used for a script that tells the visitor if ...
0
votes
0answers
62 views
MySQL INSERT limits [closed]
I have an action hook set up that copies a post (when published) to my own database. This has worked fine for all my test posting, but when I tried publishing a post with lengthy content, the INSERT ...
5
votes
2answers
187 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
2answers
212 views
How to create and work with custom data / tables (i.e., for arbitrary data)?
Getting started on Wordpress just today. I noticed that Wordpress created tables in a mySql database (with name *.wrdp1) when I first set it up. These tables cover comments, posts, users, and some ...