10quality / wp-query-builder
Wordpress Query Builder class library for custom models and data querying.
Installs: 9 210
Dependents: 0
Suggesters: 0
Security: 0
Stars: 36
Watchers: 6
Forks: 4
Open Issues: 3
Requires
- php: >=5.4
- 10quality/php-data-model: ^1.0
Requires (Dev)
- phpunit/phpunit: 9.*
README
This package provides a SQL query builder class built on top of WordPress core Database accessor. Usability is similar to Laravel's Eloquent.
The library also provides an abstract class and a trait to be used on data models built for custom tables. The abstract class extends our generic PHP model class.
This is the perfect package to use within the WordPress MVC framework.
Install
This package / library requires composer.
composer require 10quality/wp-query-builder
Usage & Documentation
Please read the wiki for documentation.
Quick snippet sample:
$books = wp_query_builder() ->select( 'ID' ) ->select( 'post_name AS name' ) ->from( 'posts' ) ->where( ['post_type' => 'book'] ) ->get(); foreach ( $books as $book ) { echo $book->ID; echo $book->name; }
Coding Guidelines
PSR-2 coding guidelines.
License
MIT License (c) 2019 10 Quality.