Run the following composer command to include in your project our database query builder and a solution for data models based on custom data tables.
composer require 10quality/wp-query-builder
WP Query Builder is our database (SQL based) package solution that allows building complex database queries, has model support on custom data tables and it has plenty of customization hooks.
Read the extended documentation here.
Database query builder sample
$results = $builder::create() ->select( 'ID' ) ->select( 'post_title' ) ->from( 'posts' ) ->where( [ 'post_status' => 'publish', 'post_type' => $post_type, // Will be sanitized ] ) ->get();