The wpdb class, accessed via the $wpdb global variable, is used to interact with the WordPress database

learn more… | top users | synonyms

0
votes
0answers
16 views

Wordpress WP_Query post__in

I try to get value from database==> postmeta ==> Meta value : value Using this code $promo_value = $wpdb->get_results("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_product_id' ...
0
votes
2answers
20 views

Custom Wordpress Table wpdb

running into issues querying a custom table and getting results. As of Wordpress 3.9, I can no longer run mysql_query(), and have to use $wpdb->query(); So keeping that in mind: Old Code: <?php ...
0
votes
3answers
26 views

selecting row using wpdb which contain special symbols

I got a table with one of the column have special charaters. I inserted to the table as $sql=$wpdb->prepare( "INSERT INTO `mytable` ( `question`, `remarks`) VALUES ...
0
votes
0answers
30 views

Insert data to DB

I create plugin and that plugin, when is activate, create new table in DB.. Now i need to insert some data like (firstname, lastname..) in that table.. Here is my form : <form name="cool_form" ...
0
votes
0answers
16 views

$wpdb error : call to a member function insert() on a non-object

I'd like to add data to my custom wordpress table of my plugin, here is my code: <?php global $wpdb; $data = $_POST['name']; $wpdb->insert('ct_data' , array( 'name' => $data ), array( "%s" ...
0
votes
0answers
16 views

Get results from wordpress data custom table

Firstly i created a custom table into the wpdb : global $wpdb; $table_name = $wpdb->prefix . 'countdown_table'; $sql = ' `id` int(11) NOT NULL AUTO_INCREMENT, `styleName` varchar(255) ...
0
votes
0answers
14 views

Custom post type search shows “Not unique table/alias” error

If I search for a value on the page that shows the custom post type list ( edit.php?post_type=my_post_type ) then it returns normal results. But because I wanted to include the post meta fields in ...
0
votes
0answers
15 views

wordpress plugin admin area save settings

I am brand new in wp plugin development and i need your help cause throw web the answers that i find confused me. So i would like to make a countdown timer wp plugin for my website that will display ...
0
votes
1answer
29 views

How to fetch results from database

I'm attempting to customize a wordpress theme. I've added custom field cp_job with form submission. This indicates if the ad is either Buyer(Buying services) or Seller(selling services), which is now ...
0
votes
0answers
13 views

$wpdb->get_results in not an array

Using get_result I receive an "Invalid argument supplied for foreach()" because is not an array. I tried with get_col but I don't know how to extract the data and I don't know the difference between ...
0
votes
1answer
10 views

$wpdb variable throw this error Call to a member function get_results() on a non-object in

I've this error "Call to a member function get_results() on a non-object in" from this code: require_once($_SERVER['DOCUMENT_ROOT'] . $folder . '/wp-config.php'); ...
0
votes
0answers
37 views

Why are Wordpress e-mails full of “mysql_real_escape_string” errors? (wp-db.php)

Since recently all Wordpress e-mails, which include Woocommerce order confirmation emails, are full of errors like these: Warning: mysql_real_escape_string(): 19 is not a valid MySQL-Link resource in ...
0
votes
1answer
39 views

List of ways to access WordPress database?

I'm trying to get a complete understanding of how WordPress works with databases. I've read the documentation but I'm getting confused by all the different approaches available. So far my ...
0
votes
1answer
49 views

Retrieving posts by their date and category

I'm trying to create a plugin for displaying post titles and dates (which will be displayed as links to those posts) of a specific date range and category. So far I have managed to get to display the ...
3
votes
1answer
69 views

WP_Query to work with custom view

I have created a Database VIEW on wp_posts which selects its all columns and exposes an extra calculated columns (average). So my View is identical to wp_posts plus one column, which I want to use for ...
1
vote
1answer
35 views

$wpdb - do you have to use foreach even if there will always only be one result?

I have a $wpdb query that will always only return one result. This is a simplified version of it: $results = $wpdb->get_results ( "SELECT name FROM testTable WHERE id=1" ); Do I have to use ...
0
votes
1answer
27 views

Should I use an additional column in the DB?

I'm building a site for a client. They need a functionality where WordPress can tell if a logged in user has viewed a post in order that they might serve a notice or hide the original content. I ...
0
votes
1answer
21 views

Unknown column 'siteurl' in 'where clause' WPDB outside

I am trying to get Mysql values from outside wp. My code: define( 'BLOCK_LOAD', true ); require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php' ); require_once( $_SERVER['DOCUMENT_ROOT'] . ...
2
votes
2answers
81 views

Differences between wpdb->get_results() and wpdb->query()

Who can explain me the differences between wpdb->get_results() and wpdb->query() in making generic queries to wordpress db?
0
votes
1answer
40 views

Inserting a MySQL record into a table with an array of field names and an array of values

I see this in the Codex: $wpdb->insert( $table, $data, $format ); I'm using this type of code and it works: $wpdb->query( $wpdb->prepare( "INSERT INTO `table` ...
0
votes
1answer
28 views

Incorrect Use of wpdb::prepare()

Not sure what I am doing wrong here. I did not write this code however I am receiving the following error in WordPress: The query argument of wpdb::prepare() must have a placeholder. This message ...
0
votes
0answers
47 views

Inserting data into custom tables

I am trying to create custom input tables to send data into custom tables on the wp database. I cannot get my script to do anything. The user will enter a type of liquor, like vodka or whiskey, ...
0
votes
2answers
42 views

WPDB Prepared Delete

I am attempting to delete a row from my DB.I am using inputs from the user and I need to be able to sanitize using the prepared statement. The query itself looks like - DELETE FROM ...
0
votes
2answers
56 views

Trying to Connect to different database

I want to get list of 5 recent posts from a subdomain (not multisite) to show on our main domain. Following is the code am trying to execute, but is giving the error - Invalid arguments supplied in ...
0
votes
1answer
20 views

Outputting query results

I am trying to make plugin, and i followed codex, i am not a OOP literate, hence i a blank. I tried to run this query $myrows = $wpdb->get_results( "SELECT question FROM wp_quiz" ); while i tried ...
0
votes
0answers
14 views

adding a log row log table, when the draft post publish

i wrote some codes, about wpdb update query. but update_post meta works fine but, wpdb update query doesn't. where am i wrong ? here is the code ; add_action('publish_post', ...
1
vote
1answer
202 views

MySQL LIKE not working

It seems MySQL's LIKE operator behaves like a = operator. The following MySQL query returns the expected result (1 entry): $meta_key = '_locality'; $meta_value = 'The Hague'; $post_ids = ...
0
votes
1answer
53 views

plugin ajax to external php file always return null

I am struggling with this error for a while now. The plugin inserts data to the table. Here's the code : File : plugin/_add.php require_once('../../../wp-load.php'); global $wpdb; $table_name = ...
0
votes
0answers
17 views

Output terms based on custom fields

This question is rather specific. In my custom posttype "sak", I have a taxonomy called "vvpl". This taxonomy has a custom field called "revision" because a term have copies based on how many ...
0
votes
2answers
75 views

Object method calling for global $wpdb in header.php

I am developing a Wordpress plugin in an object oriented way, and I would like to read data from the wordpress database using the global $wpdb variable. The global $wpdb variable is called from ...
0
votes
0answers
12 views

Separate Register Login

I plan to create a bespoke login and register feature on my WordPress Frontend. These users won't have access to the backend of WP. Just to a frontend area. Should i store the information submitted ...
0
votes
1answer
16 views

Update vs Insert logic but the last key is always inserted?

I have added a custom db table which looks like usermeta table, just storing some key - value pairs. But now i am stuck with the following logic a/ if key exist for a user use an update query else ...
0
votes
3answers
66 views

How to display a specific category using a custom Query?

Hi I want to display a specific category from a custom query in WordPress. My code works fine and it gets the latest 4 posts, but what I want now is to retrieve a specific category. My code is below ...
0
votes
2answers
29 views

$wpdb->get_var multiple queries in one database check

I am using the $wpdb->get_var php code to get the first name and last name on the records, in the wp_usermeta table... But because the field value is stored in the same cell, I don't know how to merge ...
0
votes
2answers
89 views

How To Get Some Data From WordPress Database Using WordPress $wpdb Query?

I am trying to get some data from WordPress database tables in a plugin. For that, I am using the below code... global $wpdb; $findID = $wpdb->get_var("SELECT ID FROM wp_posts WHERE post_name = ...
0
votes
2answers
207 views

Call to a member function get_results() on a non-object in wordpress plugin

I am using revolution slider plugin. I got above error while executing one of my front end form. This is my code in that file.. <?php class UniteDBRev{ private $wpdb; private $lastRowID; ...
0
votes
0answers
83 views

$wpdb->get_results(…) returns empty array despite correct query

As title implies, I cannot seem to get $wpdb->get_results to give results. Running the "raw" query is successful, but this seems to be failing for some strange unknown reason. global $wpdb; ...
0
votes
1answer
80 views

What is _transient_random_seed for?

This is a very short question. _transient_random_seed is in wp_options. What is it for?
0
votes
1answer
41 views

How can I retrieve data from alternate database using wpdb class?

I'm attempting to retrieve data from a separate WordPress installation on the same server. I'm able to use the wpdb class to successfully connect to the alternate database and get results, however, I ...
0
votes
1answer
29 views

How to avoid conflicts with db.php / $wpdb and other plugins that decide to use them?

Our plugin (VersionPress) needs to track database changes so that it can version-control them. We currently do this by creating db.php and overriding the $wpdb instance in it but it has an issue that ...
0
votes
0answers
18 views

Issue On WordPress multisite its create new table for each user

I am using WordPress for multisite all configuration are right, but it's create new table for each user like (wp_1_options, wp_2_options, wp_3_options etc for each table) it's a very big issue for me. ...
0
votes
1answer
19 views

Multi-site site nav, wpdb->prepare missing argument

I'm using a Wordpress Multi-site to house a number of sites in one WP install I'd like to have a nav showing each site with a link to the site. I'm using this function to do this <?php ...
1
vote
1answer
68 views

Wordpress SQL query - returning 'true' 'false' or 'null'

I am working on coding a PHP form for my website that requires the user to enter a code before the form becomes active. I have a field called "used" that I set up as a Boolean/TinyInt which I thought ...
0
votes
0answers
27 views

How to make iteration on wpdb->update or query statement?

I want to change post_names with iteration; I have similar post names and want to change them by foreach iteration. Initial post name is "one-book" and there are 30 similar names. I want to change ...
0
votes
1answer
37 views

Exclude specific terms from all queries using posts_where or something similar

Basically what I'm trying to do is exclude all posts that belong to a specific set of terms from showing in any and all queries across the board, EXCEPT when you're actually viewing that post or page. ...
0
votes
1answer
46 views

Advanced SELECT query with condtional statements

I am having trouble understanding the proper way to write an advanced select query. I have the following the code here. if (!empty($_GET['3321body_type'])) { $bt = $_GET['3321body_type']; ...
0
votes
1answer
23 views

At what point during a typical request does the $wpdb object become available?

I've wrote some custom SQL queries inside a class method and noticed they seem to work if I hook the method to the wp action. If I hook to the plugins_loaded action, they don't seem to work. My ...
1
vote
0answers
37 views

Codex: Database Description: meaning of Cardinality

The following post outlines how to word cardinality is commonly used when dealing with databases: http://stackoverflow.com/questions/10621077/what-is-cardinality-in-databases. However I have not been ...
0
votes
1answer
16 views

wp_commentdata: error in documentation?

The page http://codex.wordpress.org/Database_Description#Table:_wp_commentmeta lists the meta_id field of the wp_commentdata table as being both PRIMARY KEY and DEFAULT NULL. But a primary key cannot ...
0
votes
1answer
72 views

WP_USE_EXT_MYSQL

Here is the constructor for the wpdb class as found in the source code. According to a google search this has been recently renamed from USE_EXT_MYSQL. However I cannot find anywhere in the source ...