Skip to main content
Share Your Experience: Take the 2024 Developer Survey
3 votes

How does wordpress link columns from different tables without using FOREIGN KEY or JOIN?

It doesn't. WordPress doesn't use foreign keys to link tables together that way. There are also lots and lots of other reasons to declare keys and primary keys in a table that have nothing to do with ...
Tom J Nowell's user avatar
  • 59.4k
3 votes
Accepted

How to use wp-query to search for posts where post_content OR post_title OR post_name

In WordPress 6.2+, within WP_Query you can set search_columns parameter (not documented at time of writing) to specify the fields to search: $query = new WP_Query( array( 's' => '...
Caleb's user avatar
  • 1,782
2 votes
Accepted

WPDB query suddenly not working

You should only interact with the DB via WP, not directly. It's not a big deal in your case because you just want to see a value, but you'll be more aligned with the best practices if you go in trying ...
alex's user avatar
  • 116
2 votes

how to run tests using different db connection

Changing the DB connection used by a WPDB object that already exists or passing it a mysqli instance is not possible. And if it was, it still wouldn't work for other reasons. if you want to access a ...
Tom J Nowell's user avatar
  • 59.4k
1 vote
Accepted

wp db request without refreshing the page

Instead of querying the database directly, you could use WP_User_Query, but you'll get the best results by querying the REST API endpoint with a GET request at /wp-json/wp/v2/users which already lists ...
Tom J Nowell's user avatar
  • 59.4k
1 vote

problem in using wpdb->prepare and a string placeholder

Using %i instead of %s puts backticks ` around it instead of ' that works for table names
Leo's user avatar
  • 121

Only top scored, non community-wiki answers of a minimum length are eligible