Quantcast
Channel: Question and Answer » wpdb
Browsing index pages (44 articles)

$wpdb->last_error deosn't show the query on error

I am inserting data in the custom table using the $wpdb->insert. However, upon error I don’t seem to get any information from $wpdb->last_error. What could be the cause of this? I already have...

View Article


Cannot access the thumbnails of attachment images… Cannot find the reason

I have a custom form that allows users to make posts and also upload images with it. The images are saved in wp_posts as post_type = attachment with a guid to show the image. Now I have created a grid...

View Article


How To Use WP_Query To Get The Custom Post type Posts With Keywords

I want to query with keywords and display some related posts on custom taxonomy page, the related posts comes from a custom post type “gift”. I have tried the code below, but it only worked for default...

View Article

Why Do I Still Getting Duplicate Rows in SQL?

I’m creating a Custom Freight System which stores the order and the products requested by the user into the WordPress Database. The Problem When I insert the product into the wp_my_custom_products...

View Article

Get users within a latitude / longitude radius, based on custom fields

I’ve create two custom fields for my users: latitude longitude Here’s my code. I think I’m close: $user_query = $wpdb->get_results( " SELECT u.ID, u.user_login, latitude.meta_value,...

View Article


WordPress wpdb->insert returns int(0) => doesn't insert anything, no errors!

I am really clueless. I want to do an insertion in my WordPress plugin the problem is it doesn’t return any errors nor it insert the stuff! I don’t know how to fix this and really need your help. In...

View Article

wpdb get_row database query inquiry

Is this the right way to use get_row with a select *? $_crds = $wpdb->get_row($wpdb->prepare(" SELECT * FROM `mailers` WHERE `id` = %d", $_GET['caId'] )); $_zipcodes = $_crds->zipcodes;...

View Article

Include post_status check within $wpdb query

I’ve got a function that returns a count from the database for publish posts that match the product ID to the post meta ID (both are the product type). I’ve realized this query returns unpublished...

View Article


WPDB Multiple site's posts and get featured images

I am using the code below to query 5 WordPress sites for their posts, merging them into an array, sorting the array by date, and then displaying them: //SITE 1 $mydb = new...

View Article


Does WordPress $wpdb functions wait when table is locked?

Does WordPress’ $wpdb functions wait when the table is locked? For example Function A() uses $wpdb->getresults. When $wpdb->getresults wants to read a table and its locked, does it wait for...

View Article

Custom Query – Based on user input

I’m working on displaying suggestions to an input, assisting the user. I’m using the included jQuery suggest. That’s loading – and through ajax I’m using a custom SQL query and can see it’s attempting...

View Article

Processing a lot of $wpdb isn't insert all the data

In my plugin the user provides some CSV files that are processed and either inserted or updated based on a sku (which acts as a foreign key to my DB and a primary key for where the CSV comes from). I...

View Article

WPDB – Read and write value from / to database

I have a custom field in usermeta called vatnumber. If the field has a value, how do I read that specific value for user X? Here’s what I have so far: <tr class="vatnumber"> <th><?php...

View Article


$wpdb to insert html form information

I’m trying to insert posted variables from a form. When I shorten the amount of variables I’m inserting it will sometime pass the information in my mysql database. Once I continue to add on information...

View Article

wpdb get_results() returns only 2 rows

I am trying to create custom admin widget to present how many users has registered within last days. I have created function as below: function mdbootstrap_add_dashboard_recent_users(){ global $wpdb;...

View Article


Getting id of poll from WP database

So I have a php statement: $latest_pollsid that contains a number which increases by 1 every time a specific form is submitted. I am reading this statement into several functions and for one of these...

View Article

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' => $feedback_comment );...

View Article


Geographical proximity query using post_meta

I realise this might be an inefficient query, but I’m trying to grab latitude and longitude values from the post_meta table that are connected to posts to figure out the proximity of the posts to a...

View Article

Why is an empty result an error? ( $wpdb->get_row )

I have a query where I get the highest id from a table. $user_id = $wpdb->get_row("SELECT * FROM $table WHERE id=(SELECT MAX(id) FROM $table)") The table should always have rows, but if for some...

View Article

Unique user tables between three sites with same database

I have three websites that have their own prefixes, but are in the same database and have each member, and I have create a system that would allow to confine all its members in a mime table, so to...

View Article
Browsing index pages (44 articles)


Latest Images