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

learn more… | top users | synonyms

0
votes
1answer
129 views

Altering term_id and name via $wpdb class

$s = $_POST['submitterms']; $querystr = " SELECT $wpdb->terms.* FROM $wpdb->terms WHERE lower($wpdb->terms.name) like '%$s%' "; ...
5
votes
2answers
770 views

Can i use php sql functions instead of $wpdb?

I'm new to WordPress and was wondering why in WordPress API do they tell you to use functions such as prepare(), insert(), get_col(), get_row(), query(), etc. when technically I can use the built-in ...
0
votes
1answer
461 views

SQL query not working in alphabetical post title/content search

I have an ajax request using wp_ajax sending one variable named "q" what I want to do is after the script get's the request to look inside the db and fetch the title and id of the corresponding posts ...
0
votes
2answers
311 views

Disable (or limit) queries when certain content (or data) is not needed (or showed)

Currently I am making a custom design for a site. The problem I'm seeing in Wordpress is about almost all data pulled out from the database. While in certain pages - like front-page.php - it only ...
0
votes
1answer
190 views

get_var is neither a string, integer, or array …?

$vote_count = $wpdb->get_var($wpdb->prepare("SELECT votes FROM wp_mytable WHERE product = %s AND company = %s", $product, $company)); ...
0
votes
1answer
778 views

PHP variables in mysql query

What is the consensus on how to insert variables in a MySQL query using the $wpdb->insert syntax: ($table, array($column=>$value),$format)? I know this hasn't worked: ...
0
votes
1answer
609 views

Wordpress db prepare

I am not trying to use $wpdb->insert, but prepare. Insert method will have one query string and an array which includes # of data which is not defined but will be defined for each query string ...
3
votes
3answers
2k views

SELECT max(meta_value) FROM wp_postmeta WHERE meta_key='price'… stops working when value is over 999

Overview: I am not trying to return a post. I simply want the single highest value for a particular meta_value across all posts... just the value itself. Details: I have added a custom meta_key ...
2
votes
1answer
976 views

get_results on large datasets

I am experimenting some very disturbing problem using a custom SQL query. I have a custom MySQL table called trading_datas having 165 lines for 4,4Mo. One field datas of my table is a big serialized ...
2
votes
1answer
75 views

How wordpress accesses its own database

Hi I'm just curious as to how Wordpress accesses it's own database, meaning that when I look into an admin page like link-manager.php or class-wp-list-table.php I don't see any occurences of $wpdb. ...
0
votes
1answer
602 views

Query the links Database

Hi I'm trying to convert from a "example" wp_list_table that displays an array of data on the same page, to a "real life" table the pulls data from the database. I have the code setup to where I just ...
0
votes
1answer
284 views

wpdb->insert not inserting first variable

I have a strange error here. im trying to write to the wordpress db but $wpdb->insert does not write the variable first name. Can any one spot the error in this code? function ...
1
vote
3answers
1k views

how does $wpdb differ to WP_Query?

I'm going to write a function to return the next/prev post in a specific category. can anyone tell me what the differences would be in using $wpdb as opposed to WP_Query(); eg new WP_Query(args)? what ...
2
votes
2answers
4k views

WordPress Paginate $wpdb->get_results

Due to a complex multisite config, I have a query which combines the posts from two blogs and I would like to paginate the results. I am grateful for any help. I have posted my query. ...
2
votes
1answer
772 views

dbDelta only creates the last table

I'm using following install function with dbDelta as referring to the codex, articles on SO I watched out for the typical problems with e.g. one space instead of two spaced at the PRIMARY KEY ... ...
1
vote
1answer
311 views

Which action does wp_update_user triggers?

I am working modifying an ecommerce plugin, and it makes uses of wp_update_user() function, and everytime the function runs another table (created by the plugin), gets updated too. The problem is that ...
0
votes
1answer
265 views

Why does this WPDB code throw an empty WPDB error? [closed]

I'm writing a feed reader plugin for wordpress. I'm seeing a DB error that I can't figure out. First I create a table called user_entries. Then I put a sample entry into that table. When I try to ...
0
votes
2answers
2k views

Use have_posts() with array of post results retrieved by $wpdb->get_results

I don't know if I'm retarded, crazy or just plain genius or not, but I've decided to use tags as a way to link content site-wide (a big ol' many-to-many relationship website for archiving various ...
0
votes
1answer
177 views

how to translate countries output from wp database?

i have a list of countries in french stored in my database (wp_country). i use the code above to retrieve all the countries witth this ecohing echo '"' . $country['name_country'] . '",'; it outputs ...
3
votes
2answers
3k views

Retrieving custom fields with $wpdb->get_results

I'm trying to use $wpdb->get_results to retrieve an array of all posts including custom fields. I can retrieve the meta_key and meta_value columns like this: [meta_key] => state [meta_value] ...
0
votes
2answers
472 views

include wp-blog-header not working on MAMP

To clarify my question... My plugin is/was using AJAX to call the file pluginname/submit/pick.php My pluginname/pluginname.php contains the usual plugin header and wordpress automatically finds it. ...
0
votes
2answers
300 views

Fetching review value using wpdb class

I'm generating an XML file using PHP for a website where they review tech products. In the XML file, I have to display the rating of products. For rating purposes, I'm using GD Star Rating plugin. ...
2
votes
0answers
294 views

post_content getting cut off on blank space on $wpdb->update

I am publishing the following post via xmlrpc <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><head><meta ...
0
votes
1answer
156 views

How to reference same column name but different table in custom db query

I use wpdb to connect to a custom db, then I use the following query: $my_row = $wpdb_c->get_results("SELECT Employee.Name, Area.Name, Area.Region FROM Area INNER JOIN Employee ON Area.ID = ...
0
votes
2answers
371 views

Get comments after specific date

I don't think this is a parameter in get_comments( $args ); so I'm using a SQL statement. First I obtain a comment date from a separate table I created. Afterwards, I want to retrieve all comments ...
1
vote
2answers
60 views

plugin code is pulling information from database in one instance and not in other. What is wrong?

In my plugin code, I am pulling the table id from two tables. The id is being pulled from one table but not from the other and I get errors in both instances. The queries work on mysql when I use ...
0
votes
2answers
739 views

Ajax call in wordpress not working for subscriber user

All In my application there is notification system, when user click on that icon I want to make ajax call. The problem id it works fine for admin user (Debug : 200 ok), but not for subscriber user ...
1
vote
2answers
531 views

wpdb Custom Meta Data with 2 conditions

This is one of those problems that I've spent way too much time on, and there is probably a VERY simple solution that I am missing. Any help would be greatly appreciated. I am trying to populate a ...
1
vote
0answers
183 views

How to display users with posts published between two dates (Sorted by Post-Count) [Multisite]

I'm trying to make a list of users who have published posts within two given dates. My attempts using WP_User_query just work for one blog ID and takes time to load because it runs through a lot of ...
0
votes
3answers
352 views

Retrieving custom field array value through db query

I'm trying to query the database for posts based on multiple custom fields. This is easy enough with the code below if values are simple: $querydetails = " SELECT wposts.* FROM ...
0
votes
1answer
472 views

Best practice to import user base (subscribers) from one website to another?

I want to import users from a Wordpress installation to another. Same domain, but complete different websites. Website A (old, 700 users): running WP3.0 plain installation + BBPress 1.x Website B ...
0
votes
2answers
366 views

wordpress $wpdb works only once

I am working on a plugin that needs to run many different queries. I created a class that has many functions and all these functions runs different queries. A DAL basically. Now when I call these ...
0
votes
1answer
154 views

Use Loop or direct database query?

In one of my form input, the options are a list of posts. I can use the loop to get the posts, but, getting things from database table is faster, right? I see plugins sometimes use db directly, ...
0
votes
1answer
1k views

$wpdb->num_rows doesn't work

I'm trying to perform some checks on custom fields before they are saved on a db. So I decided to use an add_filter as it does this between browser and db. Here is my code function ...
0
votes
1answer
123 views

Insert data through a script directly in the db

is it possible to insert data through a script or HTML site into the wpdb and this will show up as normal article in the, the same as when I use the 'create new post' page? Which tables are affected ...
0
votes
1answer
353 views

Can't seem to get set_blog_id working, it just doesn't reset the blog ID

Trying to iterate through a list of the sites and I can't seem to get set_blog_id working. Here's the sample output: Array ( [0] => stdClass Object ( [blog_id] => 2 ) [1] => stdClass Object ( ...
1
vote
1answer
572 views

Retrieving multisite blog IDs, somehow failing to foreach them properly

Working on a directory listing and have cobbled together the shortest query I can. It appears to return the listing ok (I think) but the foreach is somehow failing to process the array properly. Can ...
0
votes
1answer
59 views

Linked pages from plugin on front can't see $wpdb

I obviously need more knowledge re this one. From my plugin. I have a custom main page which displays my custom db data table of a list of stores. Each store has a "link" ie using a href eg. <a ...
0
votes
2answers
319 views

How to obtain a reference to $table_prefix in $wpdb object

I need to call the WordPress options table and pull some data. However, the table name may be different (typically wp_options) depending on whether the default table prefix was used on installation. ...
1
vote
2answers
530 views

Mysql query LIKE not working

I'm using this code. $blog_list = $wpdb->get_results( "SELECT " . $extra . "blog_id, last_updated FROM " . $wpdb->blogs. " WHERE public = '1' AND archived = '0' AND mature = '0' AND spam = '0' ...
1
vote
1answer
1k views

passing variables as parameters to stored procedures via wpdb from php-script

i am having a slight problem with passing php-variables to a stroed procedure call from a php-script. Here comes the details: This is how it works very perfect - passing the params as string: ...
1
vote
1answer
760 views

using $wpdb to insert a form into a post

I am wanting to take the following form, and use $wpdb to insert it into a post. I have tried reading the class reference page INSERT rows, but I don't really know what should be referenced. I am not ...
2
votes
2answers
682 views

Query WP data with the WPDB API from outside WordPress

I'm working on a project with WP, a bit like a plugin, but not quite one. I'm encountering an issue, when trying to include a file that contains some custom SQL functions in a class, in a completely ...
4
votes
1answer
340 views

Query causing load because of SQL_CALC_FOUND_ROWS post counting?

I found this query causing some load in the server, my hosting provdier asked me to look on it. SELECT SQL_CALC_FOUND_ROWS wp_posts I think this select no. rows found in wp_posts table.. but i ...
0
votes
1answer
301 views

Jeditable Plugin working as it should - scope issue?

I am using the Jeditable plugin to enable inline editing on a table inside the admin area, generated by a small plugin I've written. (http://www.appelsiini.net/projects/jeditable). Basically ...
0
votes
2answers
468 views

Trouble inserting string containing quotations marks with wpdb in save_post hook

I'm having trouble with inserting a string which is containing quotation marks in wordpress via wpdb. I've written a hook for save_post and trying to write the post_title in a table via wpdp->update. ...
1
vote
3answers
2k views

Help With MySQL to WPDB Query Conversion

I have a problem. I've got a PHP script that tracks individual file downloads, and I'm looking for a way to display that number in individual posts. I've got a half-baked solution- a plain ol' MySQL ...
0
votes
1answer
287 views

What's wrong with this wpdb query?

I want to select some tags with the same term_group, I tested it in phpadmin, the query get the correct result, but once add $wpdb flavor, it returns an empty array. Any advice? $primary_tag_id = // ...
1
vote
1answer
892 views

Programmatically Creating Page using $wpdb and getting 404 error

EDIT: Turns out I had a permalink issue that was causing the 404 error. Original Posting below: I am creating a page programmatically using $wpdb->insert() and the resulting page returns a 404 ...
1
vote
2answers
415 views

Bootstrapping Wordpress MultiSite Outsite of Wordpress - No $wpdb

I'm working on a plugin for a system to use Wordpress as the authentication backend, so that I can use my existing Wordpress users in another application. The plugin works great when running in single ...