https://github.com/ignitekit/wp-query-builder
Simple query builder for WordPress
https://github.com/ignitekit/wp-query-builder
Last synced: 10 months ago
JSON representation
Simple query builder for WordPress
- Host: GitHub
- URL: https://github.com/ignitekit/wp-query-builder
- Owner: IgniteKit
- License: mit
- Created: 2023-08-19T04:38:43.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-11-22T21:54:48.000Z (about 1 year ago)
- Last Synced: 2025-03-25T10:39:22.544Z (10 months ago)
- Language: PHP
- Size: 89.8 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# WordPress Query Builder Library
[](https://packagist.org/packages/10quality/wp-query-builder)

[](https://packagist.org/packages/10quality/wp-query-builder)
[](https://packagist.org/packages/10quality/wp-query-builder)
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.
This package is inspired by the [WordPress MVC's](https://www.wordpress-mvc.com/) Query Builder.
## Install
This package / library requires composer.
```bash
composer require ignitekit/wp-query-builder
```
## Usage & Documentation
Please read the [wiki](https://github.com/ignitekit/wp-query-builder/wiki) for documentation.
Quick snippet sample:
```php
$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](https://www.10quality.com/).
MIT License (c) 2023 [Darko G](https://darkog.com/).