Unlock your potential with a Pro Membership
Here is where you propel your career forward. Come join us today. Learn more.
Deeper Dive into $wpdb->get_results
Lab: Advanced SQL – Get Posts Grouped by Terms
Video Runtime: 05:54
Let’s look closer at WordPress Core for the object
$wpdb->get_results(). You’ll see that it’s a wrapper for the PHP constructs:
mysql_query– PHP 5.5 or less (it’s been removed from PHP 7)
mysqli_query– PHP 5 and 7
We’ll also discover that WordPress provides a filter event where the
$query is exposed. This event is named “query.” We’ll convert our plugin to remove the snippet from
get_results and build a callback for the “query” event. You can use this callback whenever you need to analyze or customize a query.
You’ll also do a quick overview of the fast approach code.
Hands off the keyboard. Web development starts by thinking first, then planning it out, and then coding it.
Total Lab Runtime: 02:46:48
- 1 Lab Introductionfree 14:27
- 2 Slow Approach Overviewpro 12:11
- 3 Test Slow Approach - Part 1pro 17:27
- 4 Test Slow Approach - Part 2pro 21:07
- 5 Relational Typespro 23:20
- 6 Types of Joinspro 09:30
- 7 Joining Metadatapro 12:37
- 8 Joining Posts to Termspro 20:32
- 9 Grouping Datasetspro 08:32
- 10 WordPress SQL Handler $wpdbpro 11:01
- 11 Deeper Dive into $wpdb->get_resultspro 05:54
- 12 Run Fast Approach & Compare Resultspro 10:10