Questions tagged [mysql]

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

3
votes
0answers
1k views

Wordpress Deadlock Error

I see more of this error these days in error_log. I see that someone asked this question here a year ago but no solution. Please advise what is causing this issue. Already, tried deactivating some ...
3
votes
0answers
325 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 ...
2
votes
0answers
31 views

Keeping database within limits, please help!

I have a website that auto generates odds data to mysql table via cron job every 2hrs. Over time the data in my table is exceeding the limit set from my hosting of 100mb. I want to stop my table from ...
2
votes
0answers
150 views

Find duplicate posts with same slug and author

We imported over 250K posts into our multi-author WordPress database but have found duplicate posts where the same author has multiple posts with the same slug. Could you please recommend a MySQL ...
2
votes
0answers
103 views

$wpdb->get_results() does not fetch results with unicode 'WHERE' clause

I've just a simple query to fetch a students records by his name, written in Bengali. $student_rcrd = $wpdb->get_results("SELECT * FROM student WHERE name='আবুল কালাম আজাদ'"); Although my database ...
2
votes
0answers
34 views

Get the Plugin Which Triggered a MySql Query in Wordpress?

I am currently working on this plugin, which is similar to Query Monitor in which i Have displayed all the Details present in the $wpdb object. Now i need to find which plugin is Triggering the Query. ...
2
votes
0answers
225 views

Error: MySQL shutdown unexpectedly. XAMPP local conf running WordPress

I have a xampp configurated locally to run wordpress. I must have done something wrong when fixing some issues 'cuz at the end, I got stuck with the following log from mysql database. 2015-11-10 15:...
2
votes
0answers
111 views

Is the usage of ON DELETE CASCADE wrong or not allowed on wordpress?

I have table with foreign key reference and i recently changed the create table query with ON DELETE CASCADE $wpdb->query("DROP TABLE IF EXISTS $table_name2"); //CREATE TABLE ...
2
votes
0answers
1k views

Database with mixed collation (utf8mb4 & utf8_general_ci)

Each time I was uploading my WP install from offline to online, I was noticing strange characters in text and digging a bit I have discovered that wp-config.php on the online server was set to define('...
2
votes
0answers
133 views

How can I make wordpress suppress mysql errors?

Wordpress has two functions related to SQL queries and their errors as mentioned in What Is The Difference Between suppress_errors() And hide_errors() in $wpdb? From what I've read setting WP_DEBUG ...
1
vote
0answers
23 views

Return terms from multiple taxonomies using $wpdb

I would be the first to admit that I know next to nothing about SQL queries, but after numerous searches and some trial and error I was able to cobble together a query that returned the results I was ...
1
vote
0answers
26 views

Is it safe to convert tables from MyISAM to InnoDB?

I have inherited a WP site (with WP5.1 and WooCommerce 2.6.14, LearnDash 2.5.4 and few other smaller plugins). From screenshot you can see that it is a mix and match of MyISAM and InnoDB tables. ...
1
vote
0answers
47 views

How to delete all customer user account that haven't placed a single order?

Recently I've had an influx of spam users registering on my Wordpress website and I am trying to delete them all if: they have a "Customer" role haven't placed at least one order before As I could ...
1
vote
0answers
44 views

how to solve slow WordPress site caused by attachment_metadata

My WordPress sites starting to become slower by time, after two years they become very slow. I tried many things, such as: improved my DB, used cache plugins (WP Rocket and W3 Total Cache) which both ...
1
vote
0answers
22 views

How to delete posts that does not have a thumbnail?

I have a problem with my blog. The thing is this, all the posts have a thumbnail in this address: wpbv_postmeta-->meta_key-->thumb And several (A LOT) of posts don't work, because I have made a ...
1
vote
0answers
14 views

Randomised Post Time

I've imported a Drupal site to Wordpress with an archive of 1000s of posts which had been backdated by adding a custom taxonomy 'Year' rather than by adjusting the post date. I've been able to remove ...
1
vote
0answers
57 views

Wordpress plugin creation how to execute .sql in order to insert multiple rows at activation of plugin

I am creating a wordpress plugin which upon activation i create my database table. I have an .sql file which has ~2000 rows of data and i would like to execute it after the creation of my database ...
1
vote
0answers
9 views

Ordering users by custom user meta

I have a list of users, and I would like to select a few to appear at the beginning of the "faculty" page, and then display the rest afterward in alphabetical order. With the following code (...
1
vote
0answers
85 views

Emojis getting converted to “?”

Emojis in posts and comments on a 500+ posts blog get converted automatically into single question marks in irregular and untraceable intervals. The respective tables wp_comments and wp_posts are ...
1
vote
0answers
83 views

How to implement a new row_count method in Wordpress?

Overview By far, Wordpress, Implements pagination by means of SQL_CALC_ROWS_FOUND. But my benchmark have shown that this implementation is 1.1 Million % slower than my queries without it. So I am ...
1
vote
0answers
197 views

How do I query wp_options for expired transient pairs with MySQL commands?

I'm working on scanning the WordPress database from the MySQL CLI (so not using PHP to query) and getting results for expired or expiring transient pairs. The trick is the pairs have the same string ...
1
vote
0answers
142 views

Long running queries

I'm trying to build a PHP script that will pull the 10 most read posts (weekly) and will return me an XML file (so I can link it to Mailchimp). Im also using - Post Views Stats Wordpress plugin by ...
1
vote
0answers
113 views

Insert data from .sql file in wordpress plugin

I'm creating a wordpress plugin that need to create a table and insert location data to that. There are more than 50000 locations in that INSERT query, so that in separate .sql file. I need to run ...
1
vote
0answers
69 views

How to split links generated into an xml sitemap to avoid exceeding 30 sec maximum execution time?

So I am trying to push these kind of URLs into a sitemap www.example.com/used-cars/location/new-york/model/audi & www.example.com/used-cars/model/bmw This code seems to do exactly that: ` ...
1
vote
0answers
148 views

get_posts() and WP_query limits 'AND' conditions to a maximum of 6 for meta value queries in Wordpress

The get_posts() function and WP_query in WordPress is limiting me to a maximum of 6 AND conditions for meta value queries. Can I force get_posts() to work with more than 6 AND conditions? Below is ...
1
vote
0answers
66 views

SQL Database, repeated tables?

On moving a site to localhost I noticed there are 150 tables? On further investigation it appears that many of the tables are repeated. For example: siwp206985_wp_wfHoover --> utf8_general_ci ...
1
vote
0answers
40 views

Assign External Database Queries to Global Variables and Make Them Accessible

I've got a bit of a tough question involving a website and its web app counterpart. The Background The website relies on two different databases: its default, named wp_website, and its counterpart's ...
1
vote
0answers
40 views

Get a listing of portfolio items and categories

On my website I maintain a list of links to cases we’ve worked at. The cases themselves contain descriptions plus two small lists, showing who worked on the case and what other cases exist in the same ...
1
vote
0answers
17 views

Would this post meta be better added to the post table rather than post_meta table

I have a function that records the post views, and my post loops can be ordered by post views. This is the code: /** * Set Post views * */ function hp_global_set_post_views() { if (!is_single()...
1
vote
0answers
268 views

wp query foreach deleting record returning only first or last item

I need your help on a subject that is out of my knowledge. So, a short story what's going on. I'm developing a WordPress plugin for a company that wants to have custom casting platform for its actors....
1
vote
0answers
39 views

SQL to migrate post types to taxonomy

It's been about 5 years since had to touch a database so please bear with me. I've just taken over a site that has posts split up by post types, and I need to merge all those posts into the default ...
1
vote
0answers
288 views

How do I join a $wpdb query with user meta using default value if not exist?

I am implementing a new feature to a website which gives users a certain amount of credits every week, if they are of a certain membership level. We are using Paid Memberships Pro and MyCred. Both ...
1
vote
0answers
115 views

database sent to a JSON file

I'm looking into creating an admin (content management) system with wordpress. However I need the database data to be sent to my application in a specific JSON file. Is there a way of accessing the ...
1
vote
0answers
356 views

Visual/Text Editor displays blank pages in WP-Admin- but HTML on client side displays correctly

Theme: Hemingway, Twenty-Sixteen Host: Bluehost Browser(s): Safari, Chrome OS: OSX El Capitan 10.10.5 (14F1605) Website When I try to "Edit Page" visual editor screen is blank, in both Text and ...
1
vote
0answers
70 views

How to translate this mySQL query to $wpdb query

I'm having trouble recreating a query from straight mySQL to $wpdb compatible. SELECT meta_value FROM `wp_postmeta` WHERE meta_key = 'review_rating' AND meta_value = 5 AND post_id IN (118,117,116,...
1
vote
0answers
91 views

MySql query to get posts with all meta and terms

I'm trying to figureout a way to get all fields from wp_post with all of their custom fields and categories in one mysql query. So in one row of the result I should have post fields with their custom ...
1
vote
0answers
42 views

Trouble Migrating all data blog from Wordpress.com to Wordpress.org

I'm transferring a WordPress.com blog to a new WordPress.org website but I'm having trouble transferring everything. I've gone through the usual WordPress tools - export XML file, import using the ...
1
vote
0answers
292 views

inserting a post from an extern php file but post content doesn't show on wp site

I'm doing a php file that insert post's on my wordpress site. I'm filling all the fields in wp_posts, but the content doesn't shows on my wordpress site. I wonder if it's because the categories are ...
1
vote
0answers
1k views

Proper usage of $wpdb->update()?

I am trying to update my custom table in Wordpress using the following php code but still no success: $tablename = "wpfeedback"; $data = array( 'mark' => $mark, 'comment' => $...
1
vote
0answers
1k views

Manually query posts by taxonomy with MySQL

I'm trying to query posts from the WP database with the category uncategorised, while also joining the post meta table, but I can't get it to work. I get an empty result. This is my query SELECT * ...
1
vote
0answers
121 views

Regarding “Insert query error” in wordpress

I am getting "Insert query error" in my WordPress eCommerce website when I click on the place order button. My error is: Insert query error - Table 'i1503672_wp6.wp_wa_product_orders' doesn't exist ...
1
vote
0answers
35 views

How to add a private user page populated from sql?

I have taken over management of a Boy Scout website for around 75 kids. The site is a vanilla WordPress site and has no access control (other than admin). I would like a scout/parent to be able to ...
1
vote
0answers
485 views

Wordpress page and plugin list using sql query

I want to get all published pages and activated plugins of my word press site,i want all pages and plugin using mysql query.i don't want to copy paste all pages from wp admin.i want to get this list ...
1
vote
0answers
939 views

mysql_real_escape_string() vs. esc_sql() in WordPress

Does mysql_real_escape_string() and esc_sql() in WordPress both do the same thing? I tried the following: $fetch_row='<p>And again for single posts</p>' echo mysql_real_escape_string( $...
1
vote
0answers
202 views

Alter wp_post table vs. post_meta performance/speed

I'm searching for the most efficient way to link a post to multiple users. By default each post in wp_post has a post_author column, which is linked to the corresponding user ID in wp_users. Assume ...
1
vote
0answers
764 views

Set Display Name to first and last name (phpmyadmin SQL Query)

I'm trying to change all the users Display Names to be their first and last name. I have looked into a number of plugins and wrote my own PHP to try and accomplish this however the site has over 50,...
1
vote
0answers
1k views

SQL query equivalent to WP User Query

I have the following WP user query code: //Get all users sorted by whatever $sorted_users = new WP_User_Query(array( 'orderby' => 'meta_value', 'meta_key' => 'satisfaction_rating', '...
1
vote
0answers
795 views

Using $wpdb (WPDB class) 'replace' with multiple WHERE criteria problem

I have two fields that are used to identify a particular row (acting as a composite key). If it does not exist, I wish to insert a new row. The REPLACE function (http://codex.wordpress.org/...
1
vote
0answers
147 views

MySQL query to mass change role of users

I'm looking for a MySQL query to achieve this purpose: Change the role of users that never posted and have registered before at least 60 days. The role to be changed to is a new role to be created ...
1
vote
0answers
908 views

wpdb custom tables without plugin

I am using custom tables, with $wpdb, trying to perform basic queries at the moment. I can't find anything on manually creating tables then using them with $wpdb, everything is plugin related. I ...