This is the second, and final part, in a series about – as the title suggests – direct database queries. Specifically, it’s about changing post statuses (but it’s relevant to more than that).
This is yet another post that’s going to be an illustration of how to use $wpdb to quickly update information based on metadata.
And the code provided in that post works but if you’re looking to make it more object-oriented, then there’s more work that can be done.
Before jumping into the actual post, though, it’s important to note that when it comes to object-oriented programming, there’s a lot of work that can go into the class design and creating levels of abstraction.
At some point, you have to draw the proverbial line between when you’re going to use interfaces, how granular your classes are going to be in terms of what they are abstracting, and the like.
And the purpose of this post is to help provide a better object-oriented design but it’s not an exercise is making this as optimal as possible. I do discuss topics like this in another series of posts.
But keep that in mind when reading through the code throughout the rest of the post.