The difference is what is returned.
The WPDB query()
method returns true
for CREATE, ALTER, TRUNCATE and DROP queries, an integer of how many results for all other queries, or simply false
if if there’s an error.
The WPDB get_results()
method actually returns the entire result of the query (like you would get running the query in phpMyAdmin). You can return the result as an array or an object, depending on how you want to work with the results.
Related Posts:
- Differences between wpdb->get_results() and wpdb->query()
- How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
- wpdb get posts by taxonomy SQL
- Multipart/formatted MySQL query problem
- Custom $wpdb Query for Custom Post Type by Category
- Can’t pass table to $wpdb->prepare
- $wpdb->get_var not returning a result
- Most effective use of DB querys
- wpdb::prepare() isn’t working
- $wpdb doesn’t appear to work on page inside of a plugin
- Strange string in console from wpdb query
- Using $wpdb->update but confused on the WHERE in and SET
- Update slug (URL) of pending posts via phpMyAdmin
- What’s wrong with my $wpdb prepare?
- Make one query for adding entries to database
- How to execute a SQL-query which contains multiple queries using $wpdb->query?
- Alter a specific query on WordPress
- wpdb->term_taxonomy count posts from both published and private posts?
- wpdb print all post meta
- Plugin will sort users by usermeta
- wpdb query problem to access previous 3 days posts
- How to write: $wpdb->update having WHERE NOT value pair in the array
- I can’t figure out what’s wrong with this statement. $wpdb->query update
- Use mysql_query instead of $wpdb query
- wpdb COALESCE won’t work
- Custom Query – Based on user input
- Custom SQL Query passing array to WHERE p.id
- Get posts from category with custom query
- Custom Query returns array, but I can’t see it’s elements
- Valid SQL query return empty
- mysql query – how to escape apostrophe?
- $wpdb->prepare affecting the query?
- prepare function sql safe method
- Updating with $qpdb->query() always returns 0 rows affected
- How to return count of custom post type posts with a specific custom field value via $wpdb?
- WordPress Mysql query and Duplicate
- How do I query for posts by custom meta and those that have been stickied?
- Help with Related Posts Function
- wpdb update multiple row?
- Formatting a date/time returned from a custom $wpdb query
- Improve performance of slow query
- How do I get specific readable results from this query and array results
- Display data from phpMyAdmin with WordPress
- implementing my wp_query using $wpdb class
- Exclude Posts from a Widget
- Fastest and most efficient SQL query to check if UID exists
- Use $wpdb->get_results with filter based on array
- $wpdb query for price in custom field value
- Display result from custom post meta query
- Wpdb empty result only if language is Russian
- Run an update query in a function
- How to fix this insert? Don’t work for me!
- Problem on wpdb queries, wp_insert_post, wp_insert_user etc. The query runs twice
- Update vs Insert logic but the last key is always inserted?
- There is way to improve this query? wordpress get post data and some meta data
- $wpdb: how to use a query as a base for another query?
- Wpdb generates too many queries
- Custom Query for searching through custom fields
- Mysql query and odd results
- How to reference same column name but different table in custom db query
- Retrieving custom field array value through db query
- How to get one result using wpdb class?
- Delete query won’t run
- update $wpdb one query
- Get Terms by IDs with IDs order
- wpdb::prepare was called incorrectly
- Slow wp_enqueue_media()
- The use of including upgrade.php when building custom queries
- Mysql / WordPress killing my server with 80k users [closed]
- Query all posts and not repeat the same tag
- How many queries are normal to execute on a WP site?
- Insert static element only once in query archive
- How to run a mysql query when admin updates user role?
- Error when using setup_postdata()
- SQL query to select posts from multiple categories
- Iterating through $wpdb query without using get_results for large query results
- Select Query demand excesive resources [closed]
- Create Indexes for Slow Queries
- I want to create a filter for the query string is this possible?
- Exclude categories from the_category();
- How can i show all categories using wp query?
- Query returning same results even though the ID changes
- Why my query ‘REPLACE INTO…’ does not work?
- Restrict query to last day with posts
- Custom query object with Simple-Fields custom date field
- Customizing the_tags output?
- Querying with WP query using meta key price
- Re-sort get_posts query results
- create a link to a random post within the current category
- Pagination not working on custom post types with rewrite slug
- update_post_meta not working in template_redirect action
- Sort by postmeta on when searching
- Pulling an ACF into a query
- Using cron for multiple queries
- Proper way to trigger a MySQL query via link in a plugin
- Set posts per page for parent category and it’s all children
- Exclude sticky posts from query
- Rewrite Query_Var URL Parameter with Slug
- How to query different categories on index?
- Print data from wordpress sql query